diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 9de587ab..00000000 --- a/build.gradle +++ /dev/null @@ -1,261 +0,0 @@ -buildscript { - repositories { - // These repositories are only for Gradle plugins, put any other repositories in the repository block further below - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - mavenCentral() - } - dependencies { - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - } -} - -plugins { - id 'net.minecraftforge.gradle' version '5.1.+' - id 'org.parchmentmc.librarian.forgegradle' version '1.+' - id 'net.darkhax.curseforgegradle' version '1.0.11' - id "com.modrinth.minotaur" version "2.+" - id 'maven-publish' - id "io.freefair.lombok" version "6.6-rc1" -} - -apply plugin: 'org.spongepowered.mixin' - -group = 'com.github.manasmods' -version = "${minecraftVersion}-${modVersion}" -archivesBaseName = modId - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -minecraft { - mappings channel: 'parchment', version: "${parchmentVersion}-${minecraftVersion}" - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', "${modId}" - - mods { - manascore { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', "${modId}" - - mods { - manascore { - source sourceSets.main - } - } - } - - gameTestServer { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', "${modId}" - - mods { - manascore { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - args '--mod', "${modId}", '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - manascore { - source sourceSets.main - } - } - } - } -} - -mixin { - add sourceSets.main, "${modId}.refmap.json" - - config "${modId}.mixins.json" -} - -// Include resources generated by data generators. -sourceSets.main.resources { srcDir 'src/generated/resources' } - -repositories { - // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: - // flatDir { - // dir 'libs' - // } - maven { - name = "manasmods" - credentials { - username project.findProperty('manasmodsUsername') ?: System.getenv().getOrDefault('MANAS_REPO_USER', '') - password project.findProperty('manasmodsPassword') ?: System.getenv().getOrDefault('MANAS_REPO_USER_PASSWORD', '') - } - url "https://manasmods.bytesafe.dev/maven/manasmods" - } -} - -dependencies { - minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" - annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' -} - -// Example for how to get properties into the manifest for reading at runtime. -jar { - manifest { - attributes([ - "Specification-Title" : "manascore", - "Specification-Vendor" : "ManasMods", - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "ManasMods", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - -jar.finalizedBy('reobfJar') - -def replaceResources = tasks.register("replaceResources", Copy) { - it.outputs.upToDateWhen { false } - //Copy it into the build dir - it.from(sourceSets.main.resources) { - def forgeLoaderVersion = forgeVersion.substring(0, forgeVersion.indexOf('.')) - def nextMinecraftVersion = getNextMajorMinecraftVersion(minecraftVersion) - def minecraftVersionCheck = "[${minecraftVersion},${nextMinecraftVersion})" - - include "META-INF/mods.toml" - expand 'modVersion': "${modVersion}", - 'forgeLoaderVersion': "[${forgeLoaderVersion},)", - 'minecraftVersionCheck': "${minecraftVersionCheck}", - 'modId': "${modId}" - } - it.into "$buildDir/resources/main/" -} - -static String getNextMajorMinecraftVersion(String currentVersion) { - def version = currentVersion.substring(0, currentVersion.indexOf('.')) - def majorVersion = currentVersion.substring(currentVersion.indexOf('.') + 1, currentVersion.indexOf('.', currentVersion.indexOf('.') + 1)) - def majorInt = Integer.valueOf(majorVersion) - majorInt++ - majorVersion = majorInt.toString() - return "${version}.${majorVersion}" -} - -processResources { - duplicatesStrategy(DuplicatesStrategy.FAIL) - exclude('META-INF/mods.toml') - configure { finalizedBy(replaceResources) } -} - -classes.configure { - dependsOn(replaceResources) -} - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} - -task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { - dependsOn build - - apiToken = project.findProperty('curseforge_apikey') ?: System.getenv('CF_TOKEN') - def mainFile = upload(619025, jar) - mainFile.releaseType = 'release' - mainFile.displayName = "${minecraftVersion}-${modVersion}" - mainFile.changelog = file('CHANGELOG.md') - mainFile.changelogType = 'markdown' - mainFile.addModLoader('Forge') - mainFile.addGameVersion(minecraftVersion) -} - -modrinth { - token = project.findProperty('modrinth_apikey') ?: System.getenv('MODRINTH_TOKEN') - projectId = "wRRSWpd1" - versionType = "release" - versionName = "${minecraftVersion}-${modVersion}" - uploadFile = tasks.jar - gameVersions = [project.minecraftVersion] - loaders = ["forge"] - changelog = file('CHANGELOG.md').text -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - name = "ManasCore" - url "https://api-g.cloudsmith.io/maven/manasmods/manascore/" - credentials { - username = project.findProperty("cloudsmith_user") ?: System.getenv("CLOUDSMITH_USER") - password = project.findProperty("cloudsmith_password") ?: System.getenv("CLOUDSMITH_PASSWORD") - } - } - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index b552f4b9..00000000 --- a/gradle.properties +++ /dev/null @@ -1,11 +0,0 @@ -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false -# Minecraft data -minecraftVersion=1.19.3 -# Forge date -forgeVersion=44.1.0 -# Parchment Version -parchmentVersion=2022.12.18 -# Mod Information see https://mcforge.readthedocs.io/en/1.18.x/gettingstarted/versioning/#examples -modVersion=2.1.0.0 -modId=manascore \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f..00000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e750102e..00000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100644 index c53aefaa..00000000 --- a/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# 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/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${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"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || 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 - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# 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 deleted file mode 100644 index 107acd32..00000000 --- a/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "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. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -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. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="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 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 18ef4aa6..00000000 --- a/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { url "https://maven.minecraftforge.net/" } - maven { url = 'https://maven.parchmentmc.org' } - } -} - -rootProject.name = 'ManasCore' \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/ManasCore.java b/src/main/java/com/github/manasmods/manascore/ManasCore.java deleted file mode 100644 index 507f0c3a..00000000 --- a/src/main/java/com/github/manasmods/manascore/ManasCore.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore; - -import com.github.manasmods.manascore.attribute.ManasCoreAttributes; -import lombok.Getter; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -@Mod(ManasCore.MOD_ID) -public final class ManasCore { - public static final String MOD_ID = "manascore"; - @Getter - private static final Logger logger = LogManager.getLogger(); - - public ManasCore() { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - ManasCoreAttributes.register(modEventBus); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/attribute/AttributeModifierHelper.java b/src/main/java/com/github/manasmods/manascore/api/attribute/AttributeModifierHelper.java deleted file mode 100644 index 3a561774..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/attribute/AttributeModifierHelper.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.attribute; - -import lombok.experimental.UtilityClass; -import lombok.extern.log4j.Log4j2; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraft.world.entity.ai.attributes.AttributeInstance; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.util.Optional; -import java.util.UUID; - -@AvailableSince("1.0.0.0") -@UtilityClass -@Log4j2 -public final class AttributeModifierHelper { - /** - * Safe way to apply {@link AttributeModifier} to an {@link LivingEntity} - * - * @param entity Target Entity - * @param attribute Target Attribute - * @param modifier Attribute modifier - */ - public static void setModifier(final LivingEntity entity, final Attribute attribute, final AttributeModifier modifier) { - AttributeInstance instance = entity.getAttribute(attribute); - - if (instance == null) { - log.error("Tried to modify an unknown Attribute: {}", ForgeRegistries.ATTRIBUTES.getKey(attribute)); - return; - } - - double oldMaxHealth = attribute == Attributes.MAX_HEALTH ? entity.getMaxHealth() : 0; // Store old max health or 0 - Optional.ofNullable(instance.getModifier(modifier.getId())) //Get old modifier if present - .ifPresent(modifier1 -> instance.removeModifier(modifier1.getId())); //Remove old modifier - - instance.addPermanentModifier(modifier); //Add modifier - - if (attribute == Attributes.MAX_HEALTH) { - double newMaxHealth = entity.getMaxHealth(); - if (newMaxHealth > oldMaxHealth) { - double healAmount = (newMaxHealth - oldMaxHealth); - entity.heal((float) healAmount); //Heal entity by the amount of gained health - } else { - if (entity.getHealth() > newMaxHealth) { - entity.setHealth((float) newMaxHealth); //Reduce the entity health to the new max value - } - } - } - } - - /** - * @param entity Target Entity - * @param attribute Target Attribute - * @param attributeModifierId A unique id to identify this {@link AttributeModifier} - * @param attributeModifierName A unique name which is used to store the {@link AttributeModifier} - * @param amount Will be used to calculate the final value of the {@link Attribute} - * @param attributeOperation Mathematical operation type which is used to calculate the final value of the {@link Attribute} - */ - public static void addModifier(final LivingEntity entity, final Attribute attribute, final UUID attributeModifierId, final String attributeModifierName, final double amount, - final AttributeModifier.Operation attributeOperation) { - setModifier(entity, attribute, new AttributeModifier(attributeModifierId, attributeModifierName, amount, attributeOperation)); - } - - /** - * Safe way to remove {@link AttributeModifier} from Entities - * - * @param entity Target Entity - * @param attribute Target Attribute - * @param attributeModifierId Unique modifier id - */ - public static void removeModifier(final LivingEntity entity, final Attribute attribute, final UUID attributeModifierId) { - Optional.ofNullable(entity.getAttribute(attribute)).ifPresent(attributeInstance -> attributeInstance.removeModifier(attributeModifierId)); - } - - /** - * Safe way to remove {@link AttributeModifier} from Entities - * - * @param entity Target Entity - * @param attribute Target Attribute - * @param modifier Modifier - */ - public static void removeModifier(final LivingEntity entity, final Attribute attribute, final AttributeModifier modifier) { - removeModifier(entity, attribute, modifier.getId()); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/attribute/package-info.java b/src/main/java/com/github/manasmods/manascore/api/attribute/package-info.java deleted file mode 100644 index 717063fb..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/attribute/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.attribute; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/client/gui/FontRenderHelper.java b/src/main/java/com/github/manasmods/manascore/api/client/gui/FontRenderHelper.java deleted file mode 100644 index ffe42f0a..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/gui/FontRenderHelper.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.gui; - -import com.mojang.blaze3d.vertex.PoseStack; -import lombok.experimental.UtilityClass; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.util.FormattedCharSequence; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.awt.Color; -import java.util.List; - -@OnlyIn(Dist.CLIENT) -@AvailableSince("1.0.1.0") -@UtilityClass -public final class FontRenderHelper { - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final Color color) { - renderScaledTextInArea(poseStack, font, text, x, y, width, height, color, 0F); - } - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final int color) { - renderScaledTextInArea(poseStack, font, text, x, y, width, height, color, 0F); - } - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final Color color, - final float spacePerLine) { - renderScaledTextInArea(poseStack, font, text, x, y, width, height, color, spacePerLine, 0.01F); - } - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final int color, - final float spacePerLine) { - renderScaledTextInArea(poseStack, font, text, x, y, width, height, color, spacePerLine, 0.01F); - } - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final Color color, - final float spacePerLine, final float scalingSteps) { - renderScaledTextInArea(poseStack, font, text, x, y, width, height, color.getRGB(), spacePerLine, scalingSteps); - } - - public static void renderScaledTextInArea(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final float height, final int color, - final float spacePerLine, final float scalingSteps) { - float scaling = 1F; - - while (true) { - List formattedCharSequences = font.split(text, Math.round(width / scaling)); - if (formattedCharSequences.size() * (font.lineHeight + spacePerLine) * scaling > height) { - scaling -= scalingSteps; - } else { - break; - } - } - - renderScaledText(poseStack, - font, - scaling, - font.split(text, Math.round(width / scaling)), - x, - y, - color, - spacePerLine - ); - } - - public static void renderScaledWrappedText(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final Color color) { - renderScaledWrappedText(poseStack, font, text, x, y, width, color, 0); - } - - public static void renderScaledWrappedText(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final int color) { - renderScaledWrappedText(poseStack, font, text, x, y, width, color, 0); - } - - public static void renderScaledWrappedText(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final Color color, - final float spacePerLine) { - renderScaledWrappedText(poseStack, font, text, x, y, width, color.getRGB(), spacePerLine); - } - - public static void renderScaledWrappedText(final PoseStack poseStack, final Font font, final FormattedText text, final float x, float y, final float width, final int color, - final float spacePerLine) { - float scaling = 1F; - - while (true) { - List sequences = font.split(text, Minecraft.getInstance().getWindow().getScreenWidth()); - float currentScaling = scaling; - int maxWidth = sequences.stream() - .map(seq -> font.width(seq) * currentScaling) - .mapMultiToInt((aFloat, intConsumer) -> intConsumer.accept(Math.round(aFloat))) - .max() - .orElse(0); - if (maxWidth > width) { - scaling -= 0.01F; - } else { - break; - } - } - - renderScaledText(poseStack, - font, - scaling, - font.split(text, Math.round(width / scaling)), - x, - y, - color, - spacePerLine - ); - } - - private static void renderScaledText(final PoseStack poseStack, final Font font, final float scaling, final List text, final float x, float y, final int color, - final float spacePerLine) { - poseStack.scale(scaling, scaling, scaling); - - for (FormattedCharSequence charSequence : text) { - font.draw(poseStack, charSequence, x / scaling, y / scaling, color); - y += (font.lineHeight + spacePerLine) * scaling; - } - - poseStack.scale(1 / scaling, 1 / scaling, 1 / scaling); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/gui/package-info.java b/src/main/java/com/github/manasmods/manascore/api/client/gui/package-info.java deleted file mode 100644 index 22e38564..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/gui/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.client.gui; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/ImagePredicateButton.java b/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/ImagePredicateButton.java deleted file mode 100644 index e822712d..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/ImagePredicateButton.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.gui.widget; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -/** - * Simple button which gets rendered while the render check is true - */ -@AvailableSince("1.0.0.0") -public class ImagePredicateButton extends Button { - private final ResourceLocation texture; - private final RenderCheck renderCheck; - - public ImagePredicateButton(int pX, int pY, int pWidth, int pHeight, ResourceLocation texture, OnPress pOnPress, Tooltip tooltip, RenderCheck renderCheck) { - super(new Builder(Component.empty(), pOnPress) - .pos(pX, pY) - .size(pWidth, pHeight) - .tooltip(tooltip) - ); - this.texture = texture; - this.renderCheck = renderCheck; - } - - public void hideToolTip() { - setTooltip(null); - } - - @Override - public void renderButton(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) { - active = renderCheck.check(); - - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.enableDepthTest(); - if (active) { - blit(pPoseStack, this.getX(), this.getY(), 0, isHoveredOrFocused() ? height : 0, width, height, width, height * 2); - } else { - blit(pPoseStack, this.getX(), this.getY(), 0, height, width, height, width, height * 2); - } - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/RenderCheck.java b/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/RenderCheck.java deleted file mode 100644 index c4ee89ce..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/RenderCheck.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.gui.widget; - -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -@FunctionalInterface -public interface RenderCheck { - boolean check(); -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/package-info.java b/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/package-info.java deleted file mode 100644 index 83b523e7..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/gui/widget/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.client.gui.widget; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/KeybindingCategory.java b/src/main/java/com/github/manasmods/manascore/api/client/keybinding/KeybindingCategory.java deleted file mode 100644 index 7f7b5e22..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/KeybindingCategory.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.keybinding; - -import com.github.manasmods.manascore.ManasCore; -import lombok.RequiredArgsConstructor; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; - -@AvailableSince("1.0.0.0") -@NonExtendable -@RequiredArgsConstructor(staticName = "of") -public final class KeybindingCategory { - private final String id; - - public String getCategoryString() { - return String.format("%s.category.%s", ManasCore.MOD_ID, this.id); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybinding.java b/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybinding.java deleted file mode 100644 index 83add22a..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybinding.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.keybinding; - -import com.mojang.blaze3d.platform.InputConstants; -import lombok.Getter; -import net.minecraft.client.KeyMapping; -import net.minecraftforge.client.settings.KeyConflictContext; -import net.minecraftforge.fml.common.Mod; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -public class ManasKeybinding extends KeyMapping { - @Getter - private final KeyBindingAction action; - - /** - * Creates a Keybinding which handles the given action automatically. - * No need to create an {@link Mod.EventBusSubscriber}. - * - * @param langKey Translation String - * @param defaultKey Default Key - * @param category Category - * @param action Action when pressed - */ - public ManasKeybinding(String langKey, int defaultKey, KeybindingCategory category, KeyBindingAction action) { - this(langKey, InputConstants.Type.KEYSYM.getOrCreate(defaultKey), category, action); - } - - /** - * Creates a Keybinding which handles the given action automatically. - * No need to create an {@link Mod.EventBusSubscriber}. - * - * @param langKey Translation String - * @param defaultKey Default Key - * @param category Category - * @param action Action when pressed - */ - public ManasKeybinding(String langKey, InputConstants.Key defaultKey, KeybindingCategory category, KeyBindingAction action) { - super(langKey, KeyConflictContext.UNIVERSAL, defaultKey, category.getCategoryString()); - this.action = action; - } - - /** - * Creates a Keybinding without a default key. - * - * @param langKey Translation String - * @param category Category - * @param action Action when pressed. - */ - public ManasKeybinding(String langKey, KeybindingCategory category, KeyBindingAction action) { - this(langKey, InputConstants.UNKNOWN.getValue(), category, action); - } - - - @FunctionalInterface - public interface KeyBindingAction { - void onPress(); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybindings.java b/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybindings.java deleted file mode 100644 index 9cd07e3d..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/ManasKeybindings.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.client.keybinding; - -import com.github.manasmods.manascore.client.keybinding.KeybindingRegistry; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; - -@AvailableSince("1.0.0.0") -@NonExtendable -public final class ManasKeybindings { - /** - * Registers {@link ManasKeybinding} to ManasCore and Minecraft. - * This has to be used in the mod constructor - */ - public static void register(ManasKeybinding... keybinding) { - KeybindingRegistry.register(keybinding); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/package-info.java b/src/main/java/com/github/manasmods/manascore/api/client/keybinding/package-info.java deleted file mode 100644 index 9ec39b83..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/client/keybinding/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.client.keybinding; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockLoot.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockLoot.java deleted file mode 100644 index f5d363e7..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockLoot.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.DoorDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.LeavesDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.OreDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.OtherDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.SelfDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.SlabDrop; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockLoot.WithLootTables; -import com.github.manasmods.manascore.api.util.ReflectionUtils; -import lombok.extern.log4j.Log4j2; -import net.minecraft.data.loot.packs.VanillaBlockLoot; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.objectweb.asm.Type; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static com.github.manasmods.manascore.api.util.StreamUtils.distinctBy; - -@AvailableSince("2.0.3.0") -@Log4j2 -public abstract class BlockLoot extends VanillaBlockLoot { - private static final Type GEN_ANNOTATION = Type.getType(GenerateBlockLoot.class); - - @NonExtendable - @Override - protected final void generate() { - loadTables(); - final List annotations = new ArrayList<>(); - ModList.get().forEachModFile(modFile -> { - modFile.getScanResult().getAnnotations() - .stream() - .filter(annotationData -> GEN_ANNOTATION.equals(annotationData.annotationType())) - .forEach(annotations::add); - }); - generateAnnotationLootTables(annotations); - } - - @NonExtendable - private void generateAnnotationLootTables(List annotations) { - annotations.forEach(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return; - - List blockRegistryObjectFieldList = Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(RegistryObject.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return Block.class.isAssignableFrom(registryObjectClass); - }) - .toList(); - - generateDropSelfLootTables(annotationData, blockRegistryObjectFieldList); - generateDropOtherLootTables(annotationData, blockRegistryObjectFieldList); - generateDropOreLootTables(annotationData, blockRegistryObjectFieldList); - generateDropLeavesLootTables(annotationData, blockRegistryObjectFieldList); - generateDropDoorLootTables(annotationData, blockRegistryObjectFieldList); - generateDropSlabLootTables(annotationData, blockRegistryObjectFieldList); - }); - } - - @NonExtendable - private void generateDropSelfLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(SelfDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - log.debug("Generating block loot for registry object {}", registryObject.getId()); - dropSelf(registryObject.get()); - } - } - - @NonExtendable - private void generateDropOtherLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(OtherDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - - OtherDrop annotation = registryObjectField.getAnnotation(OtherDrop.class); - if (annotation.value().isBlank()) continue; - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Item lootItem = ForgeRegistries.ITEMS.getValue(itemId); - if (lootItem == null) { - log.error("Could not find loot item {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block loot for registry object {}", registryObject.getId()); - dropOther(registryObject.get(), lootItem); - } - } - - @NonExtendable - private void generateDropOreLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(OreDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - - OreDrop annotation = registryObjectField.getAnnotation(OreDrop.class); - if (annotation.value().isBlank()) continue; - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Item lootItem = ForgeRegistries.ITEMS.getValue(itemId); - if (lootItem == null) { - log.error("Could not find loot item {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block loot for registry object {}", registryObject.getId()); - add(registryObject.get(), block -> createOreDrop(registryObject.get(), lootItem)); - } - } - - @NonExtendable - private void generateDropLeavesLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(LeavesDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - - LeavesDrop annotation = registryObjectField.getAnnotation(LeavesDrop.class); - if (annotation.value().isBlank()) continue; - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Block saplingBlock = ForgeRegistries.BLOCKS.getValue(itemId); - if (saplingBlock == null) { - log.error("Could not find sapling block {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block loot for registry object {}", registryObject.getId()); - add(registryObject.get(), block -> createLeavesDrops(registryObject.get(), saplingBlock, annotation.chances())); - } - } - - @NonExtendable - private void generateDropDoorLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(DoorDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - - log.debug("Generating block loot for registry object {}", registryObject.getId()); - add(registryObject.get(), this::createDoorTable); - } - } - - @NonExtendable - private void generateDropSlabLootTables(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(SlabDrop.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - - log.debug("Generating block loot for registry object {}", registryObject.getId()); - add(registryObject.get(), this::createSlabItemTable); - } - } - - protected abstract void loadTables(); - - /** - * Gets all {@link DeferredRegister} objects in {@link GenerateBlockLoot} annotated classes with {@link WithLootTables} annotation. - */ - @Override - protected Iterable getKnownBlocks() { - return ModList.get().getAllScanData() - .stream() - .flatMap(modFileScanData -> modFileScanData.getAnnotations().stream()) - .filter(annotationData -> GEN_ANNOTATION.equals(annotationData.annotationType())) - .flatMap(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return Stream.of(); - - return Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(DeferredRegister.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return Block.class.isAssignableFrom(registryObjectClass); - }) - .filter(field -> field.isAnnotationPresent(WithLootTables.class)) - .map(field -> ReflectionUtils.getDeferredRegisterFromField(annotationData, field, Block.class)) - .filter(Objects::nonNull) - .flatMap(blockDeferredRegister -> blockDeferredRegister.getEntries().stream()) - .filter(RegistryObject::isPresent) - .filter(distinctBy(blockRegistryObject -> blockRegistryObject)) - .map(RegistryObject::get); - }) - .toList(); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockStateProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockStateProvider.java deleted file mode 100644 index 11555464..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockStateProvider.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.ManasCore; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockModels; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockModels.CubeAllModel; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockModels.PillarModel; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockModels.SlabModel; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateBlockModels.StairModel; -import com.github.manasmods.manascore.api.util.ReflectionUtils; -import lombok.extern.log4j.Log4j2; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RotatedPillarBlock; -import net.minecraft.world.level.block.SlabBlock; -import net.minecraft.world.level.block.StairBlock; -import net.minecraft.world.level.block.state.properties.Half; -import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.level.block.state.properties.StairsShape; -import net.minecraftforge.client.model.generators.BlockModelBuilder; -import net.minecraftforge.client.model.generators.ConfiguredModel; -import net.minecraftforge.client.model.generators.ModelFile; -import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; -import org.objectweb.asm.Type; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.function.Supplier; - -@AvailableSince("1.0.0.0") -@SuppressWarnings("unused") -@Log4j2 -public abstract class BlockStateProvider extends net.minecraftforge.client.model.generators.BlockStateProvider { - private static final Type GEN_ANNOTATION = Type.getType(GenerateBlockModels.class); - - public BlockStateProvider(final GatherDataEvent gatherDataEvent, String modId) { - super(gatherDataEvent.getGenerator().getPackOutput(), modId, gatherDataEvent.getExistingFileHelper()); - } - - @OverrideOnly - protected abstract void generate(); - - @NonExtendable - @Override - protected final void registerStatesAndModels() { - generate(); - final List annotations = new ArrayList<>(); - ModList.get().forEachModFile(modFile -> { - modFile.getScanResult().getAnnotations() - .stream() - .filter(annotationData -> GEN_ANNOTATION.equals(annotationData.annotationType())) - .forEach(annotations::add); - }); - generateAnnotationModels(annotations); - } - - @NonExtendable - private void generateAnnotationModels(List annotations) { - annotations.forEach(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return; - - List blockRegistryObjectFieldList = Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(RegistryObject.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return Block.class.isAssignableFrom(registryObjectClass); - }) - .toList(); - - generateCubeAllModels(annotationData, blockRegistryObjectFieldList); - generatePillarModels(annotationData, blockRegistryObjectFieldList); - generateStairModels(annotationData, blockRegistryObjectFieldList); - generateSlabModels(annotationData, blockRegistryObjectFieldList); - }); - } - - @NonExtendable - private void generateCubeAllModels(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(CubeAllModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - - if (registryObject == null) continue; - CubeAllModel annotation = registryObjectField.getAnnotation(CubeAllModel.class); - // Generate default model - if (annotation.value().isEmpty() || annotation.value().isBlank()) { - log.debug("Generating block model for registry object {}", registryObject.getId()); - defaultBlock(registryObject.get(), annotation.renderType()); - continue; - } - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Block textureBlock = ForgeRegistries.BLOCKS.getValue(itemId); - if (textureBlock == null) { - log.error("Could not find texture block {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block model for registry object {} with texture of {}", registryObject.getId(), itemId); - defaultBlock(registryObject.get(), textureBlock, annotation.renderType()); - } - } - - @NonExtendable - private void generatePillarModels(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(PillarModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - if (registryObject == null) continue; - // Generate default model - log.debug("Generating block model for registry object {}", registryObject.getId()); - pillar(registryObject.get()); - } - } - - @NonExtendable - private void generateStairModels(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(StairModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - - if (registryObject == null) continue; - StairModel annotation = registryObjectField.getAnnotation(StairModel.class); - // Generate default model - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Block textureBlock = ForgeRegistries.BLOCKS.getValue(itemId); - if (textureBlock == null) { - log.error("Could not find texture block {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block model for registry object {} with texture of {}", registryObject.getId(), itemId); - stairs(registryObject.get(), textureBlock); - } - } - - @NonExtendable - private void generateSlabModels(AnnotationData annotationData, List blockRegistryObjectFieldList) { - for (Field registryObjectField : blockRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(SlabModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Block.class); - - if (registryObject == null) continue; - SlabModel annotation = registryObjectField.getAnnotation(SlabModel.class); - // Generate default model - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Block textureBlock = ForgeRegistries.BLOCKS.getValue(itemId); - if (textureBlock == null) { - log.error("Could not find texture block {} for block {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating block model for registry object {} with texture of {}", registryObject.getId(), itemId); - slab(registryObject.get(), textureBlock); - } - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(Block block) { - return Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(block)); - } - - @NonExtendable - protected final String name(Block block) { - return rl(block).getPath(); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the target {@link Block} - */ - protected void defaultBlock(Block block) { - defaultBlock(block, block); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the target {@link Block} - * @param renderType the render type - */ - protected void defaultBlock(Block block, RenderType renderType) { - defaultBlock(block, block, renderType); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the target {@link Block} - * @param textureBlock the texture providing {@link Block} - */ - protected void defaultBlock(Block block, Block textureBlock) { - defaultBlock(block, textureBlock, RenderType.DEFAULT); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the target {@link Block} - * @param textureBlock the texture providing {@link Block} - * @param renderType the render type - */ - protected void defaultBlock(Block block, Block textureBlock, RenderType renderType) { - getVariantBuilder(block).forAllStates(state -> { - if (RenderType.DEFAULT.equals(renderType)) { - return ConfiguredModel.builder() - .modelFile(cubeAll(textureBlock)) - .build(); - } else { - return ConfiguredModel.builder() - .modelFile(models() - .cubeAll(name(textureBlock), blockTexture(textureBlock)) - .renderType(renderType.getId())) - .build(); - } - }); - - itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()) - .parent(new UncheckedModelFile(modLoc("block/" + name(block)))); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param stairBlock the {@link StairBlock} Object - * @param textureBlock the {@link Block} you want to use as texture - */ - protected void stairs(Block stairBlock, Block textureBlock) { - if (!(stairBlock instanceof StairBlock block)) { - throw new IllegalArgumentException(Objects.requireNonNull(rl(stairBlock)) + " is not a instance of StairBlock."); - } else { - stairsBlock(block, new ResourceLocation(Objects.requireNonNull(rl(textureBlock)).getNamespace(), "block/" + name(textureBlock))); - itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()) - .parent(new ModelFile.UncheckedModelFile(modLoc("block/" + name(block)))); - } - } - - protected void stairs(Block stairBlock, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - if (stairBlock instanceof StairBlock block) { - String baseName = rl(block).toString(); - ModelFile stairs = overlayStair(baseName, top, bottom, side, overlay); - ModelFile stairsInner = overlayInnerStair(baseName + "_inner", top, bottom, side, overlay); - ModelFile stairsOuter = overlayOuterStair(baseName + "_outer", top, bottom, side, overlay); - - getVariantBuilder(block) - .forAllStatesExcept(state -> { - Direction facing = state.getValue(StairBlock.FACING); - Half half = state.getValue(StairBlock.HALF); - StairsShape shape = state.getValue(StairBlock.SHAPE); - int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason - if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) { - yRot += 270; // Left facing stairs are rotated 90 degrees clockwise - } - if (shape != StairsShape.STRAIGHT && half == Half.TOP) { - yRot += 90; // Top stairs are rotated 90 degrees clockwise - } - yRot %= 360; - boolean uvlock = yRot != 0 || half == Half.TOP; // Don't set uvlock for states that have no rotation - return ConfiguredModel.builder() - .modelFile(shape == StairsShape.STRAIGHT ? stairs : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter) - .rotationX(half == Half.BOTTOM ? 0 : 180) - .rotationY(yRot) - .uvLock(uvlock) - .build(); - }, StairBlock.WATERLOGGED); - - this.itemModels().getBuilder(name(block)).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(stairBlock)) + " is not a instance of StairBlock."); - } - } - - protected void sidedStairs(Block stairBlock, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - if (stairBlock instanceof StairBlock block) { - String baseName = rl(block).toString(); - ModelFile stairs = grassLikeStair(baseName, top, bottom, side); - ModelFile stairsInner = grassLikeInnerStair(baseName + "_inner", top, bottom, side); - ModelFile stairsOuter = grassLikeOuterStair(baseName + "_outer", top, bottom, side); - - getVariantBuilder(block) - .forAllStatesExcept(state -> { - Direction facing = state.getValue(StairBlock.FACING); - Half half = state.getValue(StairBlock.HALF); - StairsShape shape = state.getValue(StairBlock.SHAPE); - int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason - if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) { - yRot += 270; // Left facing stairs are rotated 90 degrees clockwise - } - if (shape != StairsShape.STRAIGHT && half == Half.TOP) { - yRot += 90; // Top stairs are rotated 90 degrees clockwise - } - yRot %= 360; - boolean uvlock = yRot != 0 || half == Half.TOP; // Don't set uvlock for states that have no rotation - return ConfiguredModel.builder() - .modelFile(shape == StairsShape.STRAIGHT ? stairs : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter) - .rotationX(half == Half.BOTTOM ? 0 : 180) - .rotationY(yRot) - .uvLock(uvlock) - .build(); - }, StairBlock.WATERLOGGED); - - this.itemModels().getBuilder(name(block)).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(stairBlock)) + " is not a instance of StairBlock."); - } - } - - protected void stairs(Block stairBlock, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - if (stairBlock instanceof StairBlock block) { - stairsBlock(block, side, bottom, top); - this.itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(stairBlock)) + " is not a instance of StairBlock."); - } - } - - protected void stairs(Block stairBlock, ResourceLocation side, ResourceLocation top) { - stairs(stairBlock, side, top, top); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param slabBlock the {@link SlabBlock} Object - * @param textureBlock the {@link Block} you want to use as texture - */ - protected void slab(Block slabBlock, Block textureBlock) { - if (!(slabBlock instanceof SlabBlock block)) { - throw new IllegalArgumentException(Objects.requireNonNull(rl(slabBlock)) + " is not a instance of StairBlock."); - } else { - ResourceLocation textureLocation = new ResourceLocation(Objects.requireNonNull(rl(textureBlock)).getNamespace(), "block/" + name(textureBlock)); - slabBlock(block, textureLocation, textureLocation); - itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + name(block)))); - } - } - - protected void slab(Block slabBlock, Block fullBlock, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - if (slabBlock instanceof SlabBlock block) { - ModelFile doubleSlab = models().getExistingFile(new ResourceLocation(rl(fullBlock).getNamespace(), "block/" + name(fullBlock))); - ModelFile bottomSlab = overlaySlab(name(block), top, bottom, side, overlay); - ModelFile topSlab = overlaySlabTop(name(block) + "_top", top, bottom, side, overlay); - - getVariantBuilder(block) - .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).addModels(new ConfiguredModel(bottomSlab)) - .partialState().with(SlabBlock.TYPE, SlabType.TOP).addModels(new ConfiguredModel(topSlab)) - .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).addModels(new ConfiguredModel(doubleSlab)); - - this.itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(slabBlock)) + " is not a instance of StairBlock."); - } - } - - protected void slab(Block slabBlock, Block fullBlock, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) { - if (slabBlock instanceof SlabBlock block) { - slabBlock(block, new ResourceLocation(rl(fullBlock).getNamespace(), "block/" + name(fullBlock)), side, bottom, top); - this.itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(slabBlock)) + " is not a instance of SlabBlock."); - } - } - - protected void slab(Block stairBlock, Block fullBlock, ResourceLocation side, ResourceLocation top) { - slab(stairBlock, fullBlock, side, top, top); - } - - protected void sidedSlab(Block slabBlock, Block fullBlock, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - if (slabBlock instanceof SlabBlock block) { - ModelFile doubleSlab = models().getExistingFile(new ResourceLocation(rl(fullBlock).getNamespace(), "block/" + name(fullBlock))); - ModelFile bottomSlab = grassLikeSlab(name(block), top, bottom, side); - ModelFile topSlab = grassLikeSlabTop(name(block) + "_top", top, bottom, side); - - getVariantBuilder(block) - .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).addModels(new ConfiguredModel(bottomSlab)) - .partialState().with(SlabBlock.TYPE, SlabType.TOP).addModels(new ConfiguredModel(topSlab)) - .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).addModels(new ConfiguredModel(doubleSlab)); - - this.itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()).parent(new ModelFile.UncheckedModelFile(this.modLoc("block/" + name(block)))); - } else { - throw new IllegalArgumentException(Objects.requireNonNull(rl(slabBlock)) + " is not a instance of StairBlock."); - } - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the {@link RotatedPillarBlock} Object. - */ - protected void pillar(Block block) { - if (!(block instanceof RotatedPillarBlock rotatedPillarBlock)) { - throw new IllegalArgumentException(Objects.requireNonNull(rl(block)) + " is not a instance of RotatedPillarBlock."); - } else { - logBlock(rotatedPillarBlock); - itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()) - .parent(new ModelFile.UncheckedModelFile(modLoc("block/" + name(block)))); - } - } - - /** - * Generates blockstate, block and item model json file. - * - * @param block the {@link RotatedPillarBlock} Object. - * @param textureTopBot the path to the texture file for the top or bottom of the Block - * @param textureSides the path to the texture file for the sides of the block - */ - protected void nonRotatablePillar(Block block, ResourceLocation textureTopBot, ResourceLocation textureSides) { - getVariantBuilder(block) - .forAllStates(blockState -> ConfiguredModel.builder().modelFile(models().cubeColumn(name(block), textureSides, textureTopBot)).build()); - itemModels().getBuilder(Objects.requireNonNull(rl(block)).getPath()) - .parent(new ModelFile.UncheckedModelFile(modLoc("block/" + name(block)))); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param sapling sapling block - */ - protected void sapling(Supplier sapling) { - sapling(sapling.get()); - } - - /** - * Generates blockstate, block and item model json file. - * - * @param sapling sapling block - */ - protected void sapling(Block sapling) { - getVariantBuilder(sapling).forAllStates(blockState -> ConfiguredModel.builder().modelFile(models().cross(name(sapling), blockTexture(sapling))).build()); - itemModels().getBuilder(Objects.requireNonNull(rl(sapling)).getPath()) - .parent(new ModelFile.UncheckedModelFile(modLoc("block/" + name(sapling)))); - } - - private BlockModelBuilder overlayStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/overlay_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top) - .texture("overlay", overlay); - } - - private BlockModelBuilder overlayInnerStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/overlay_inner_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top) - .texture("overlay", overlay); - } - - private BlockModelBuilder overlayOuterStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/overlay_outer_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top) - .texture("overlay", overlay); - } - - private BlockModelBuilder overlaySlab(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/overlay_slab")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top) - .texture("overlay", overlay); - } - - private BlockModelBuilder overlaySlabTop(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side, ResourceLocation overlay) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/overlay_slab_top")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top) - .texture("overlay", overlay); - } - - private BlockModelBuilder grassLikeStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/grass_like_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } - - private BlockModelBuilder grassLikeInnerStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/grass_like_inner_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } - - private BlockModelBuilder grassLikeOuterStair(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/grass_like_outer_stairs")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } - - private BlockModelBuilder grassLikeSlab(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/grass_like_slab")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } - - private BlockModelBuilder grassLikeSlabTop(String baseName, ResourceLocation top, ResourceLocation bottom, ResourceLocation side) { - return models().withExistingParent(baseName, new ResourceLocation(ManasCore.MOD_ID, "block/grass_like_slab_top")) - .texture("side", side) - .texture("bottom", bottom) - .texture("top", top); - } -} - diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockTagProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockTagProvider.java deleted file mode 100644 index 63189909..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/BlockTagProvider.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import net.minecraft.core.HolderLookup; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.common.Tags.Blocks; -import net.minecraftforge.common.data.BlockTagsProvider; -import net.minecraftforge.data.event.GatherDataEvent; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; - -import java.util.Arrays; -import java.util.function.Supplier; - -@AvailableSince("1.0.0.0") -public abstract class BlockTagProvider extends BlockTagsProvider { - public BlockTagProvider(GatherDataEvent gatherDataEvent, String modId) { - super(gatherDataEvent.getGenerator().getPackOutput(),gatherDataEvent.getLookupProvider(), modId, gatherDataEvent.getExistingFileHelper()); - } - - @Override - protected void addTags(HolderLookup.Provider pProvider) { - generate(); - } - - @OverrideOnly - protected abstract void generate(); - - @SafeVarargs - @NonExtendable - protected final void mineableWithAxe(Supplier... blocks) { - mineableWithAxe(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void mineableWithAxe(Block... blocks) { - tag(BlockTags.MINEABLE_WITH_AXE).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void mineableWithHoe(Supplier... blocks) { - mineableWithHoe(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void mineableWithHoe(Block... blocks) { - tag(BlockTags.MINEABLE_WITH_HOE).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void mineableWithPickaxe(Supplier... blocks) { - mineableWithPickaxe(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void mineableWithPickaxe(Block... blocks) { - tag(BlockTags.MINEABLE_WITH_PICKAXE).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void mineableWithShovel(Supplier... blocks) { - mineableWithShovel(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void mineableWithShovel(Block... blocks) { - tag(BlockTags.MINEABLE_WITH_SHOVEL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void mineableWithAllTools(Supplier... blocks) { - mineableWithAllTools(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void mineableWithAllTools(Block... blocks) { - mineableWithAxe(blocks); - mineableWithHoe(blocks); - mineableWithPickaxe(blocks); - mineableWithShovel(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsNetheriteTool(Supplier... blocks) { - needsNetheriteTool(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsNetheriteTool(Block... blocks) { - tag(Blocks.NEEDS_NETHERITE_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsDiamondTool(Supplier... blocks) { - needsDiamondTool(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsDiamondTool(Block... blocks) { - tag(BlockTags.NEEDS_DIAMOND_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsIronTool(Supplier... blocks) { - needsIronTool(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsIronTool(Block... blocks) { - tag(BlockTags.NEEDS_IRON_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsStoneTool(Supplier... blocks) { - needsStoneTool(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsStoneTool(Block... blocks) { - tag(BlockTags.NEEDS_STONE_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsWoodenTools(Supplier... blocks) { - needsWoodenTools(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsWoodenTools(Block... blocks) { - tag(Blocks.NEEDS_WOOD_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void needsGoldenTools(Supplier... blocks) { - needsGoldenTools(Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void needsGoldenTools(Block... blocks) { - tag(Blocks.NEEDS_GOLD_TOOL).add(blocks); - } - - @SafeVarargs - @NonExtendable - protected final void subTag(TagKey root, TagKey sub, Supplier... blocks) { - subTag(root, sub, Arrays.stream(blocks).map(Supplier::get).toArray(Block[]::new)); - } - - protected void subTag(TagKey root, TagKey sub, Block... blocks) { - tag(root).addTag(sub); - tag(sub).add(blocks); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/CustomDataProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/CustomDataProvider.java deleted file mode 100644 index 46c6d0a9..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/CustomDataProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ -package com.github.manasmods.manascore.api.data.gen; - -import com.google.common.collect.Maps; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import lombok.extern.log4j.Log4j2; -import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DataProvider; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; -import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.function.BiConsumer; -import java.util.function.Supplier; - -@AvailableSince("1.0.0.0") -@Log4j2 -public abstract class CustomDataProvider implements DataProvider { - @ScheduledForRemoval(inVersion = "2.1.0.0") - @Deprecated(forRemoval = true) - private static final Gson GSON = new GsonBuilder() - .setPrettyPrinting() - .create(); - private final String outputPath; - private final DataGenerator generator; - - public CustomDataProvider(String path, DataGenerator generator) { - this.outputPath = path; - this.generator = generator; - } - - @OverrideOnly - protected abstract void run(BiConsumer> consumer); - - @Override - public CompletableFuture run(CachedOutput pOutput) { - Map> map = Maps.newHashMap(); - BiConsumer> consumer = (location, jsonElementSupplier) -> { - Supplier supplier = map.put(location, jsonElementSupplier); - if (supplier != null) { - throw new IllegalStateException(String.format("Duplicate %s for %s", getName(), location)); - } - }; - - run(consumer); - - List> futures = new ArrayList<>(); - map.forEach((location, jsonElementSupplier) -> { - Path path = this.generator.getPackOutput().getOutputFolder() - .resolve("data") - .resolve(location.getNamespace()) - .resolve(this.outputPath) - .resolve(location.getPath() + ".json"); - - futures.add(DataProvider.saveStable(pOutput, jsonElementSupplier.get(), path)); - }); - - return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/EntityLoot.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/EntityLoot.java deleted file mode 100644 index 98a4e85e..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/EntityLoot.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateEntityLoot; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateEntityLoot.EmptyLootTable; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateEntityLoot.WithLootTables; -import com.github.manasmods.manascore.api.util.ReflectionUtils; -import lombok.extern.log4j.Log4j2; -import net.minecraft.data.loot.packs.VanillaEntityLoot; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.objectweb.asm.Type; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -import static com.github.manasmods.manascore.api.util.StreamUtils.distinctBy; - -@Log4j2 -public abstract class EntityLoot extends VanillaEntityLoot { - private static final Type GEN_ANNOTATION = Type.getType(GenerateEntityLoot.class); - - @NonExtendable - @Override - public final void generate() { - loadTables(); - final List annotations = new ArrayList<>(); - ModList.get().forEachModFile(modFile -> { - modFile.getScanResult().getAnnotations() - .stream() - .filter(annotationData -> GEN_ANNOTATION.equals(annotationData.annotationType())) - .forEach(annotations::add); - }); - generateAnnotationLootTables(annotations); - } - - @NonExtendable - private void generateAnnotationLootTables(List annotations) { - annotations.forEach(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return; - - List entityRegistryObjectFieldList = Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(RegistryObject.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return EntityType.class.isAssignableFrom(registryObjectClass); - }) - .toList(); - // TODO add Annotation Generators - generateEmptyLootTables(annotationData, entityRegistryObjectFieldList); - }); - } - - @NonExtendable - private void generateEmptyLootTables(AnnotationData annotationData, List entityRegistryObjectFieldList) { - for (Field registryObjectField : entityRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(EmptyLootTable.class)) continue; - @SuppressWarnings("unchecked") RegistryObject> registryObject = - (RegistryObject>) (Object) ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, EntityType.class); - if (registryObject == null) continue; - log.debug("Generating block loot for registry object {}", registryObject.getId()); - add(registryObject.get(), LootTable.lootTable()); - } - } - - protected abstract void loadTables(); - - @SuppressWarnings("unchecked") - @Override - protected Stream> getKnownEntityTypes() { - return (Stream>) (Object) ModList.get().getAllScanData() - .stream() - .flatMap(modFileScanData -> modFileScanData.getAnnotations().stream()) - .filter(annotationData -> GEN_ANNOTATION.equals(annotationData.annotationType())) - .flatMap(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return Stream.of(); - - return Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(DeferredRegister.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return EntityType.class.isAssignableFrom(registryObjectClass); - }) - .filter(field -> field.isAnnotationPresent(WithLootTables.class)) - .map(field -> ReflectionUtils.getDeferredRegisterFromField(annotationData, field, EntityType.class)) - .filter(Objects::nonNull) - .flatMap(blockDeferredRegister -> blockDeferredRegister.getEntries().stream()) - .filter(RegistryObject::isPresent) - .filter(distinctBy(entityTypeRegistryObject -> entityTypeRegistryObject)) - .map(RegistryObject::get); - }); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemModelProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemModelProvider.java deleted file mode 100644 index a4eb5af5..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemModelProvider.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateItemModels; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateItemModels.SingleHandheldTextureModel; -import com.github.manasmods.manascore.api.data.gen.annotation.GenerateItemModels.SingleTextureModel; -import com.github.manasmods.manascore.api.util.ReflectionUtils; -import lombok.extern.log4j.Log4j2; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraftforge.client.model.generators.ModelFile; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; -import org.objectweb.asm.Type; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -@AvailableSince("1.0.0.0") -@SuppressWarnings("unused") -@Log4j2 -public abstract class ItemModelProvider extends net.minecraftforge.client.model.generators.ItemModelProvider { - private static final Type GEN_MODELS = Type.getType(GenerateItemModels.class); - - public ItemModelProvider(final GatherDataEvent gatherDataEvent, String modId) { - super(gatherDataEvent.getGenerator().getPackOutput(), modId, gatherDataEvent.getExistingFileHelper()); - } - - @OverrideOnly - protected abstract void generate(); - - @NonExtendable - @Override - protected final void registerModels() { - generate(); - - final List annotations = new ArrayList<>(); - ModList.get().forEachModFile(modFile -> { - modFile.getScanResult().getAnnotations() - .stream() - .filter(annotationData -> GEN_MODELS.equals(annotationData.annotationType())) - .forEach(annotations::add); - }); - generateAnnotationModels(annotations); - } - - @NonExtendable - private void generateAnnotationModels(List annotations) { - annotations.forEach(annotationData -> { - Class clazz = null; - try { - clazz = Class.forName(annotationData.clazz().getClassName()); - } catch (ClassNotFoundException e) { - log.error("Could not load class " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (clazz == null) return; - - List itemRegistryObjectFieldList = Arrays.stream(clazz.getDeclaredFields()) - .filter(field -> Modifier.isStatic(field.getModifiers())) - .filter(field -> field.getType().equals(RegistryObject.class)) - .filter(field -> { - ParameterizedType registryObjectType = null; - try { - registryObjectType = ((ParameterizedType) field.getGenericType()); - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName()); - log.throwing(e); - } - if (registryObjectType == null) return false; - - Class registryObjectClass = null; - try { - registryObjectClass = (Class) registryObjectType.getActualTypeArguments()[0]; - } catch (ClassCastException e) { - log.error("Could not load generic type of field " + field.getName() + " in " + annotationData.clazz().getClassName() + "."); - log.throwing(e); - } - if (registryObjectClass == null) return false; - - return Item.class.isAssignableFrom(registryObjectClass); - }) - .toList(); - - generateSingleTextureModels(annotationData, itemRegistryObjectFieldList); - generateSingleHandheldTextureModels(annotationData, itemRegistryObjectFieldList); - }); - } - - @NonExtendable - private void generateSingleTextureModels(AnnotationData annotationData, List itemRegistryObjectFieldList) { - for (Field registryObjectField : itemRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(SingleTextureModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Item.class); - - if (registryObject == null) continue; - SingleTextureModel annotation = registryObjectField.getAnnotation(SingleTextureModel.class); - // Generate default model - if (annotation.value().isEmpty() || annotation.value().isBlank()) { - log.debug("Generating item model for registry object {}", registryObject.getId()); - singleTexture(registryObject.get()); - continue; - } - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Item textureItem = ForgeRegistries.ITEMS.getValue(itemId); - if (textureItem == null) { - log.error("Could not find texture item {} for item {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating item model for registry object {} with texture of {}", registryObject.getId(), itemId); - singleTexture(registryObject.get(), textureItem); - } - } - - @NonExtendable - private void generateSingleHandheldTextureModels(AnnotationData annotationData, List itemRegistryObjectFieldList) { - for (Field registryObjectField : itemRegistryObjectFieldList) { - if (!registryObjectField.isAnnotationPresent(SingleHandheldTextureModel.class)) continue; - RegistryObject registryObject = ReflectionUtils.getRegistryObjectFromField(annotationData, registryObjectField, Item.class); - - if (registryObject == null) continue; - SingleHandheldTextureModel annotation = registryObjectField.getAnnotation(SingleHandheldTextureModel.class); - // Generate default model - if (annotation.value().isEmpty() || annotation.value().isBlank()) { - log.debug("Generating item model for registry object {}", registryObject.getId()); - handheldSingleTexture(registryObject.get()); - continue; - } - - ResourceLocation itemId = ResourceLocation.tryParse(annotation.value()); - Item textureItem = ForgeRegistries.ITEMS.getValue(itemId); - if (textureItem == null) { - log.error("Could not find texture item {} for item {}", itemId, registryObject.getId()); - continue; - } - - log.debug("Generating item model for registry object {} with texture of {}", registryObject.getId(), itemId); - handheldSingleTexture(registryObject.get(), textureItem); - } - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(Item item) { - return Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)); - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final String name(Item item) { - return rl(item).getPath(); - } - - /** - * Generates the item model json file. - * Can be used for any default rendered {@link Item} object. - * - * @param item the target {@link Item} - */ - protected void singleTexture(Item item) { - singleTexture(item, item); - } - - /** - * Generates the item model json file. - * Can be used for any default rendered {@link Item} object. - * - * @param item the target {@link Item} - * @param textureItem the texture providing {@link Item} - */ - protected void singleTexture(Item item, Item textureItem) { - getBuilder(name(item)) - .parent(new ModelFile.UncheckedModelFile(mcLoc("item/generated"))) - .texture("layer0", new ResourceLocation(rl(textureItem).getNamespace(), "item/" + name(textureItem))); - } - - /** - * Generates the item model json file. - * Can be used for any handheld rendered {@link Item} like Tools and Torches. - * - * @param item the target {@link Item} - */ - protected void handheldSingleTexture(Item item) { - handheldSingleTexture(item, item); - } - - /** - * Generates the item model json file. - * Can be used for any handheld rendered {@link Item} like Tools and Torches. - * - * @param item the target {@link Item} - * @param textureItem the texture providing {@link Item} - */ - protected void handheldSingleTexture(Item item, Item textureItem) { - getBuilder(name(item)) - .parent(new ModelFile.UncheckedModelFile(mcLoc("item/handheld"))) - .texture("layer0", new ResourceLocation(rl(textureItem).getNamespace(), "item/" + name(textureItem))); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemTagProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemTagProvider.java deleted file mode 100644 index 0ecddc64..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/ItemTagProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import net.minecraft.core.HolderLookup; -import net.minecraft.data.tags.ItemTagsProvider; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraftforge.data.event.GatherDataEvent; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; - -import java.util.Arrays; -import java.util.function.Supplier; - -@AvailableSince("1.0.0.0") -public abstract class ItemTagProvider extends ItemTagsProvider { - - public ItemTagProvider(GatherDataEvent gatherDataEvent, String modId, BlockTagProvider blockTagProvider) { - super(gatherDataEvent.getGenerator().getPackOutput(),gatherDataEvent.getLookupProvider(), blockTagProvider, modId, gatherDataEvent.getExistingFileHelper()); - } - - @SafeVarargs - @NonExtendable - protected final void subTag(TagKey root, TagKey sub, Supplier... items) { - subTag(root, sub, Arrays.stream(items).map(Supplier::get).toArray(Item[]::new)); - } - - private void subTag(TagKey root, TagKey sub, Item... items) { - tag(root).addTag(sub); - tag(sub).add(items); - } - - @Override - protected void addTags(HolderLookup.Provider pProvider) { - generate(); - } - - @OverrideOnly - protected abstract void generate(); -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/LanguageProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/LanguageProvider.java deleted file mode 100644 index 40a18ca2..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/LanguageProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - - -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; - -@AvailableSince("1.0.0.0") -public abstract class LanguageProvider extends net.minecraftforge.common.data.LanguageProvider { - public LanguageProvider(GatherDataEvent gatherDataEvent, String modid) { - this(gatherDataEvent, modid, "en_us"); - } - - public LanguageProvider(GatherDataEvent gatherDataEvent, String modid, String localeCode) { - super(gatherDataEvent.getGenerator().getPackOutput(), modid, localeCode); - } - - @OverrideOnly - protected abstract void generate(); - - @Override - protected void addTranslations() { - generate(); - } - - protected void addBlock(RegistryObject obj, String value) { - add(obj.get(), value); - } - - protected void addItem(RegistryObject obj, String value) { - add(obj.get(), value); - } - protected > void addEntityType(RegistryObject obj, String value) { - add(obj.get(), value); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/RecipeProvider.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/RecipeProvider.java deleted file mode 100644 index cc42e073..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/RecipeProvider.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.core.ShapedRecipeBuilderAccessor; -import net.minecraft.advancements.RequirementsStrategy; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.RecipeBuilder; -import net.minecraft.data.recipes.RecipeCategory; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; -import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.level.ItemLike; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.common.Tags; -import net.minecraftforge.common.crafting.conditions.IConditionBuilder; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; -import org.jetbrains.annotations.ApiStatus.OverrideOnly; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.function.Supplier; - -@AvailableSince("1.0.0.0") -@SuppressWarnings({"unused", "SameParameterValue"}) -public abstract class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider implements IConditionBuilder { - public RecipeProvider(final GatherDataEvent gatherDataEvent) { - super(gatherDataEvent.getGenerator().getPackOutput()); - } - - @OverrideOnly - protected abstract void generate(Consumer pWriter); - - @Override - protected void buildRecipes(@NotNull Consumer pWriter) { - generate(pWriter); - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(Item item) { - return Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)); - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(ItemStack item) { - return rl(item.getItem()); - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(ItemLike itemLike) { - return rl(itemLike.asItem()); - } - - @AvailableSince("2.0.0.0") - @NonExtendable - protected final ResourceLocation rl(Block block) { - return rl(block.asItem()); - } - - protected void allSmeltingRecipes(Consumer pFinishedRecipeConsumer, Ingredient ingredient, RecipeCategory recipeCategory, ItemLike result, float exp, int smeltingTicks, int campfireTicks, int smokingTicks) { - smeltingRecipe(pFinishedRecipeConsumer, ingredient, recipeCategory, result, exp, smeltingTicks); - campfireRecipe(pFinishedRecipeConsumer, ingredient, result, exp, campfireTicks); - smokingRecipe(pFinishedRecipeConsumer, ingredient, result, exp, smokingTicks); - } - - protected void smeltingRecipe(Consumer pFinishedRecipeConsumer, Ingredient ingredient, RecipeCategory recipeCategory, ItemLike result, float exp, int cookingTicks) { - for (ItemStack itemStack : ingredient.getItems()) { - SimpleCookingRecipeBuilder.smelting(ingredient, recipeCategory, result, exp, cookingTicks) - .unlockedBy("has_" + getHasName(itemStack), has(itemStack.getItem())) - .save(pFinishedRecipeConsumer, getSmeltingRecipeName(result)); - } - } - - protected void campfireRecipe(Consumer pFinishedRecipeConsumer, Ingredient ingredient, ItemLike result, float exp, int cookingTicks) { - for (ItemStack itemStack : ingredient.getItems()) { - simpleCookingRecipe(pFinishedRecipeConsumer, "campfire_cooking", RecipeSerializer.CAMPFIRE_COOKING_RECIPE, cookingTicks, itemStack.getItem(), result, exp); - } - } - - protected void smokingRecipe(Consumer pFinishedRecipeConsumer, Ingredient ingredient, ItemLike result, float exp, int cookingTicks) { - for (ItemStack itemStack : ingredient.getItems()) { - simpleCookingRecipe(pFinishedRecipeConsumer, "smoking", RecipeSerializer.SMOKING_RECIPE, cookingTicks, itemStack.getItem(), result, exp); - } - } - - protected void slab(Consumer finishedRecipeConsumer, Supplier slab, TagKey tag) { - slab(finishedRecipeConsumer, slab.get(), tag); - } - - protected void slab(Consumer finishedRecipeConsumer, Block slab, TagKey tag) { - RecipeBuilder builder = slabBuilder(RecipeCategory.BUILDING_BLOCKS, slab, Ingredient.of(tag)); - builder.unlockedBy("has_" + tag.location().getNamespace(), has(tag)); - builder.save(finishedRecipeConsumer); - } - - @SafeVarargs - protected final void slab(Consumer finishedRecipeConsumer, Supplier slab, Supplier... material) { - slab(finishedRecipeConsumer, slab.get(), Arrays.stream(material).map(Supplier::get).toArray(Block[]::new)); - } - - protected void slab(Consumer finishedRecipeConsumer, Block slab, Block... material) { - RecipeBuilder builder = slabBuilder(RecipeCategory.BUILDING_BLOCKS, slab, Ingredient.of(material)); - for (Block block : material) { - builder.unlockedBy("has_" + getHasName(block), has(block)); - } - - builder.save(finishedRecipeConsumer); - } - - protected void stairs(Consumer finishedRecipeConsumer, Supplier stairs, TagKey tag) { - stairs(finishedRecipeConsumer, stairs.get(), tag); - } - - protected void stairs(Consumer finishedRecipeConsumer, Block stairs, TagKey tag) { - stairs(finishedRecipeConsumer, true, stairs, tag); - } - - protected void stairs(Consumer finishedRecipeConsumer, boolean craft8, Block stairs, TagKey tag) { - RecipeBuilder builder = craft8 ? betterStairBuilder(stairs, Ingredient.of(tag)) : stairBuilder(stairs, Ingredient.of(tag)); - builder.unlockedBy("has_" + tag.location().getNamespace(), has(tag)); - builder.save(finishedRecipeConsumer); - } - - @SafeVarargs - protected final void stairs(Consumer finishedRecipeConsumer, Supplier stairs, Supplier... material) { - stairs(finishedRecipeConsumer, stairs.get(), Arrays.stream(material).map(Supplier::get).toArray(Block[]::new)); - } - - protected void stairs(Consumer finishedRecipeConsumer, Block stairs, Block... material) { - stairs(finishedRecipeConsumer, true, stairs, material); - } - - protected void stairs(Consumer finishedRecipeConsumer, boolean craft8, Block stairs, Block... material) { - RecipeBuilder builder = craft8 ? betterStairBuilder(stairs, Ingredient.of(material)) : stairBuilder(stairs, Ingredient.of(material)); - - for (Block block : material) { - builder.unlockedBy("has_" + getHasName(block), has(block)); - } - - builder.save(finishedRecipeConsumer); - } - - protected static RecipeBuilder betterStairBuilder(ItemLike pStairs, Ingredient pMaterial) { - return ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, pStairs, 8) - .define('#', pMaterial) - .pattern("# ") - .pattern("## ") - .pattern("###"); - } - - @SuppressWarnings("ConstantConditions") - protected void stairsToBlock(Consumer finishedRecipeConsumer, Block stair, Block block) { - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, block, 3) - .requires(stair, 4) - .unlockedBy("has_" + getHasName(stair), has(stair)) - .save(finishedRecipeConsumer, new ResourceLocation(rl(block).getNamespace(), "stairs_to_block/" + rl(block).getPath())); - } - - @SuppressWarnings("ConstantConditions") - protected void slabsToBlock(Consumer finishedRecipeConsumer, Block slab, Block block) { - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, block, 1) - .requires(slab, 2) - .unlockedBy("has_" + getHasName(slab), has(slab)) - .save(finishedRecipeConsumer, new ResourceLocation(rl(block).getNamespace(), "slabs_to_block/" + rl(block).getPath())); - } - - protected void sword(Consumer finishedRecipeConsumer, ItemLike material, ItemLike sword) { - sword(finishedRecipeConsumer, Ingredient.of(material), sword); - } - - protected void sword(Consumer finishedRecipeConsumer, TagKey material, ItemLike sword) { - sword(finishedRecipeConsumer, Ingredient.of(material), sword); - } - - protected void sword(Consumer finishedRecipeConsumer, Ingredient material, ItemLike sword) { - sword(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), sword); - } - - protected void sword(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike sword) { - sword(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), sword); - } - - protected void sword(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike sword) { - sword(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), sword); - } - - protected void sword(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike sword) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, sword) - .pattern("X") - .pattern("X") - .pattern("S") - .define('X', material) - .define('S', stick); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void axe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike axe) { - axe(finishedRecipeConsumer, Ingredient.of(material), axe); - } - - protected void axe(Consumer finishedRecipeConsumer, TagKey material, ItemLike axe) { - axe(finishedRecipeConsumer, Ingredient.of(material), axe); - } - - protected void axe(Consumer finishedRecipeConsumer, Ingredient material, ItemLike axe) { - axe(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), axe); - } - - protected void axe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike axe) { - axe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), axe); - } - - protected void axe(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike axe) { - axe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), axe); - } - - protected void axe(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike axe) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, axe) - .pattern("XX") - .pattern("XS") - .pattern(" S") - .define('X', material) - .define('S', stick); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void hoe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike hoe) { - hoe(finishedRecipeConsumer, Ingredient.of(material), hoe); - } - - protected void hoe(Consumer finishedRecipeConsumer, TagKey material, ItemLike hoe) { - hoe(finishedRecipeConsumer, Ingredient.of(material), hoe); - } - - protected void hoe(Consumer finishedRecipeConsumer, Ingredient material, ItemLike hoe) { - hoe(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), hoe); - } - - protected void hoe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike hoe) { - hoe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), hoe); - } - - protected void hoe(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike hoe) { - hoe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), hoe); - } - - protected void hoe(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike hoe) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, hoe) - .pattern("XX") - .pattern(" S") - .pattern(" S") - .define('X', material) - .define('S', stick); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike pickaxe) { - pickaxe(finishedRecipeConsumer, Ingredient.of(material), pickaxe); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, TagKey material, ItemLike pickaxe) { - pickaxe(finishedRecipeConsumer, Ingredient.of(material), pickaxe); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, Ingredient material, ItemLike pickaxe) { - pickaxe(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), pickaxe); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike pickaxe) { - pickaxe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), pickaxe); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike pickaxe) { - pickaxe(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), pickaxe); - } - - protected void pickaxe(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike pickaxe) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, pickaxe) - .pattern("XXX") - .pattern(" S ") - .pattern(" S ") - .define('X', material) - .define('S', stick); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void shovel(Consumer finishedRecipeConsumer, ItemLike material, ItemLike shovel) { - shovel(finishedRecipeConsumer, Ingredient.of(material), shovel); - } - - protected void shovel(Consumer finishedRecipeConsumer, TagKey material, ItemLike shovel) { - shovel(finishedRecipeConsumer, Ingredient.of(material), shovel); - } - - protected void shovel(Consumer finishedRecipeConsumer, Ingredient material, ItemLike shovel) { - shovel(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), shovel); - } - - protected void shovel(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike shovel) { - shovel(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), shovel); - } - - protected void shovel(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike shovel) { - shovel(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), shovel); - } - - protected void shovel(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike shovel) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, shovel) - .pattern("X") - .pattern("S") - .pattern("S") - .define('X', material) - .define('S', stick); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void tools(Consumer finishedRecipeConsumer, ItemLike material, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - tools(finishedRecipeConsumer, Ingredient.of(material), axe, hoe, pickaxe, shovel, sword); - } - - protected void tools(Consumer finishedRecipeConsumer, TagKey material, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - tools(finishedRecipeConsumer, Ingredient.of(material), axe, hoe, pickaxe, shovel, sword); - } - - protected void tools(Consumer finishedRecipeConsumer, Ingredient material, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - tools(finishedRecipeConsumer, material, Ingredient.of(Tags.Items.RODS_WOODEN), axe, hoe, pickaxe, shovel, sword); - } - - protected void tools(Consumer finishedRecipeConsumer, ItemLike material, ItemLike stick, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - tools(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), axe, hoe, pickaxe, shovel, sword); - } - - protected void tools(Consumer finishedRecipeConsumer, TagKey material, TagKey stick, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - tools(finishedRecipeConsumer, Ingredient.of(material), Ingredient.of(stick), axe, hoe, pickaxe, shovel, sword); - } - - protected void tools(Consumer finishedRecipeConsumer, Ingredient material, Ingredient stick, ItemLike axe, ItemLike hoe, ItemLike pickaxe, ItemLike shovel, ItemLike sword) { - axe(finishedRecipeConsumer, material, stick, axe); - hoe(finishedRecipeConsumer, material, stick, hoe); - pickaxe(finishedRecipeConsumer, material, stick, pickaxe); - shovel(finishedRecipeConsumer, material, stick, shovel); - sword(finishedRecipeConsumer, material, stick, sword); - } - - - protected void saveWithAutoUnlock(Consumer finishedRecipeConsumer, ShapedRecipeBuilder builder, Ingredient material) { - saveWithAutoUnlock(finishedRecipeConsumer, builder, material, ""); - } - - protected void saveWithAutoUnlock(Consumer finishedRecipeConsumer, ShapedRecipeBuilder builder, Ingredient material, String filePath) { - if (material.getItems().length > 1) { - ((ShapedRecipeBuilderAccessor) builder).getAdvancement().requirements(RequirementsStrategy.OR); - } - - for (ItemStack stack : material.getItems()) { - builder.unlockedBy(getHasName(stack.getItem()), has(stack.getItem())); - } - - ResourceLocation recipeResourceLocation = RecipeBuilder.getDefaultRecipeId(builder.getResult()); - builder.save(finishedRecipeConsumer, new ResourceLocation(recipeResourceLocation.getNamespace(), filePath + recipeResourceLocation.getPath())); - } - - protected String getHasName(ItemStack stack) { - return getHasName(stack.getItem()); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, Supplier material, ItemLike packedMaterial) { - nineStorage(finishedRecipeConsumer, material.get(), packedMaterial); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, ItemLike material, Supplier packedMaterial) { - nineStorage(finishedRecipeConsumer, material, packedMaterial.get()); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, Supplier material, Supplier packedMaterial) { - nineStorage(finishedRecipeConsumer, material.get(), packedMaterial.get()); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, ItemLike material, ItemLike packedMaterial) { - nineStorage(finishedRecipeConsumer, Ingredient.of(material), packedMaterial); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, TagKey material, ItemLike packedMaterial) { - nineStorage(finishedRecipeConsumer, Ingredient.of(material), packedMaterial); - } - - protected void nineStorage(Consumer finishedRecipeConsumer, Ingredient material, ItemLike packedMaterial) { - if (material.getItems().length == 0) { - throw new IllegalStateException("No Item in material ingredient of recipe: " + rl(packedMaterial)); - } - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.MISC, packedMaterial) - .pattern("XXX") - .pattern("XXX") - .pattern("XXX") - .define('X', material); - saveWithAutoUnlock(finishedRecipeConsumer, builder, material, "storage/pack/"); - } - - protected void helmet(Consumer finishedRecipeConsumer, ItemLike material, ItemLike helmet) { - helmet(finishedRecipeConsumer, Ingredient.of(material), helmet); - } - - protected void helmet(Consumer finishedRecipeConsumer, TagKey material, ItemLike helmet) { - helmet(finishedRecipeConsumer, Ingredient.of(material), helmet); - } - - protected void helmet(Consumer finishedRecipeConsumer, Ingredient material, ItemLike helmet) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, helmet) - .pattern("XXX") - .pattern("X X") - .define('X', material); - - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void chestplate(Consumer finishedRecipeConsumer, ItemLike material, ItemLike chestplate) { - chestplate(finishedRecipeConsumer, Ingredient.of(material), chestplate); - } - - protected void chestplate(Consumer finishedRecipeConsumer, TagKey material, ItemLike chestplate) { - chestplate(finishedRecipeConsumer, Ingredient.of(material), chestplate); - } - - protected void chestplate(Consumer finishedRecipeConsumer, Ingredient material, ItemLike chestplate) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, chestplate) - .pattern("X X") - .pattern("XXX") - .pattern("XXX") - .define('X', material); - - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void leggings(Consumer finishedRecipeConsumer, ItemLike material, ItemLike leggings) { - leggings(finishedRecipeConsumer, Ingredient.of(material), leggings); - } - - protected void leggings(Consumer finishedRecipeConsumer, TagKey material, ItemLike leggings) { - leggings(finishedRecipeConsumer, Ingredient.of(material), leggings); - } - - protected void leggings(Consumer finishedRecipeConsumer, Ingredient material, ItemLike leggings) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, leggings) - .pattern("XXX") - .pattern("X X") - .pattern("X X") - .define('X', material); - - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void boots(Consumer finishedRecipeConsumer, ItemLike material, ItemLike boots) { - boots(finishedRecipeConsumer, Ingredient.of(material), boots); - } - - protected void boots(Consumer finishedRecipeConsumer, TagKey material, ItemLike boots) { - boots(finishedRecipeConsumer, Ingredient.of(material), boots); - } - - protected void boots(Consumer finishedRecipeConsumer, Ingredient material, ItemLike boots) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, boots) - .pattern("X X") - .pattern("X X") - .define('X', material); - - saveWithAutoUnlock(finishedRecipeConsumer, builder, material); - } - - protected void armour(Consumer finishedRecipeConsumer, ItemLike material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - armour(finishedRecipeConsumer, Ingredient.of(material), helmet, chestplate, leggings, boots); - } - - protected void armour(Consumer finishedRecipeConsumer, TagKey material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - armour(finishedRecipeConsumer, Ingredient.of(material), helmet, chestplate, leggings, boots); - } - - protected void armour(Consumer finishedRecipeConsumer, Ingredient material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - helmet(finishedRecipeConsumer, material, helmet); - chestplate(finishedRecipeConsumer, material, chestplate); - leggings(finishedRecipeConsumer, material, leggings); - boots(finishedRecipeConsumer, material, boots); - } - - protected void armor(Consumer finishedRecipeConsumer, ItemLike material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - armour(finishedRecipeConsumer, Ingredient.of(material), helmet, chestplate, leggings, boots); - } - - protected void armor(Consumer finishedRecipeConsumer, TagKey material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - armour(finishedRecipeConsumer, Ingredient.of(material), helmet, chestplate, leggings, boots); - } - - protected void armor(Consumer finishedRecipeConsumer, Ingredient material, ItemLike helmet, ItemLike chestplate, ItemLike leggings, ItemLike boots) { - armour(finishedRecipeConsumer, material, helmet, chestplate, leggings, boots); - } - - protected void planksFromLogs(Consumer pFinishedRecipeConsumer, Supplier pPlanks, TagKey pLogs) { - planksFromLogs(pFinishedRecipeConsumer, pPlanks.get(), pLogs, 4); - } -} \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/RenderType.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/RenderType.java deleted file mode 100644 index 1bfc4b0b..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/RenderType.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.minecraft.resources.ResourceLocation; - -@RequiredArgsConstructor -public enum RenderType { - DEFAULT(null), // pass no value into the render type (causes the builder to decide the value) - SOLID(new ResourceLocation("minecraft", "solid")), - CUTOUT(new ResourceLocation("minecraft", "cutout")), - CUTOUT_MIPPED(new ResourceLocation("minecraft", "cutout_mipped")), - CUTOUT_MIPPED_ALL(new ResourceLocation("minecraft", "cutout_mipped_all")), - TRANSLUCENT(new ResourceLocation("minecraft", "translucent")), - TRIPWIRE(new ResourceLocation("minecraft", "tripwire")); - - @Getter - private final ResourceLocation id; -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockLoot.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockLoot.java deleted file mode 100644 index 4df20599..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockLoot.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen.annotation; - -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AvailableSince("2.0.3.0") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GenerateBlockLoot { - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface WithLootTables {} - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface SelfDrop {} - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface OtherDrop { - String value(); - } - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface OreDrop { - String value(); - } - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface LeavesDrop { - String value(); - - float[] chances() default {0.05F, 0.0625F, 0.083333336F, 0.1F}; - } - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface DoorDrop {} - - @AvailableSince("2.0.3.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface SlabDrop {} -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockModels.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockModels.java deleted file mode 100644 index 4578c86a..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateBlockModels.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen.annotation; - -import com.github.manasmods.manascore.api.data.gen.RenderType; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AvailableSince("2.0.2.0") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GenerateBlockModels { - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface CubeAllModel { - /** - * ResourceLocation to the block providing a Texture - */ - String value() default ""; - - RenderType renderType() default RenderType.DEFAULT; - } - - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface PillarModel {} - - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface StairModel { - /** - * ResourceLocation to the block providing a Texture - */ - String value(); - } - - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface SlabModel { - /** - * ResourceLocation to the block providing a Texture - */ - String value(); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateEntityLoot.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateEntityLoot.java deleted file mode 100644 index 72f098b8..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateEntityLoot.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen.annotation; - -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AvailableSince("2.0.5.0") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GenerateEntityLoot { - @AvailableSince("2.0.5.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface WithLootTables {} - - @AvailableSince("2.0.5.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface EmptyLootTable {} -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateItemModels.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateItemModels.java deleted file mode 100644 index eea25f95..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/annotation/GenerateItemModels.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.data.gen.annotation; - -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AvailableSince("2.0.2.0") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GenerateItemModels { - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface SingleTextureModel { - /** - * ResourceLocation to the item providing a texture - */ - String value() default ""; - } - - @AvailableSince("2.0.2.0") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - @interface SingleHandheldTextureModel { - /** - * ResourceLocation to the item providing a texture - */ - String value() default ""; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/data/gen/package-info.java b/src/main/java/com/github/manasmods/manascore/api/data/gen/package-info.java deleted file mode 100644 index 04de5704..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/data/gen/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.data.gen; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/datapack/CodecJsonDataManager.java b/src/main/java/com/github/manasmods/manascore/api/datapack/CodecJsonDataManager.java deleted file mode 100644 index 13463ee6..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/datapack/CodecJsonDataManager.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.datapack; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.mojang.serialization.Codec; -import com.mojang.serialization.JsonOps; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.OnDatapackSyncEvent; -import net.minecraftforge.network.PacketDistributor; -import net.minecraftforge.network.simple.SimpleChannel; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; - -@AvailableSince("1.0.0.0") -public class CodecJsonDataManager extends SimpleJsonResourceReloadListener { - private static final Gson STANDARD_GSON = new Gson(); - private static final Logger LOGGER = LogManager.getLogger(); - - /** The codec we use to convert json-elements to T objects **/ - private final Codec codec; - - private final String folderName; - - /** The raw data that we parsed from json last time resources were reloaded **/ - protected Map data = new HashMap<>(); - - /** - * Creates a data manager with a standard gson parser - * - * @param folderName The name of the data folder that we will load from, vanilla folderNames are "recipes", "loot_tables", etc
- * Jsons will be read from data/all_modids/folderName/all_jsons
- * folderName can include subfolders, e.g. "some_mod_that_adds_lots_of_data_loaders/cheeses" - * @param codec A codec to deserialize the json into your T, see javadocs above class - */ - public CodecJsonDataManager(String folderName, Codec codec) { - this(folderName, codec, STANDARD_GSON); - } - - /** - * As above but with a custom GSON - * - * @param folderName The name of the data folder that we will load from, vanilla folderNames are "recipes", "loot_tables", etc
- * Jsons will be read from data/all_modids/folderName/all_jsons
- * folderName can include subfolders, e.g. "some_mod_that_adds_lots_of_data_loaders/cheeses" - * @param codec A codec to deserialize the json into your T, see javadocs above class - * @param gson A gson for parsing the raw json data into JsonElements. JsonElement-to-T conversion will be done by the codec, - * so gson type adapters shouldn't be necessary here - */ - public CodecJsonDataManager(String folderName, Codec codec, Gson gson) { - super(gson, folderName); - this.folderName = folderName; // superclass has this but it's a private field - this.codec = codec; - } - - /** - * @return The data entries - */ - public Map getData() { - return this.data; - } - - @Override - protected void apply(Map jsons, ResourceManager resourceManager, ProfilerFiller profiler) { - LOGGER.info("Beginning loading of data for data loader: {}", this.folderName); - Map newMap = new HashMap<>(); - - for (Map.Entry entry : jsons.entrySet()) { - ResourceLocation key = entry.getKey(); - JsonElement element = entry.getValue(); - // if we fail to parse json, log an error and continue - // if we succeeded, add the resulting T to the map - this.codec.decode(JsonOps.INSTANCE, element) - .get() - .ifLeft(result -> newMap.put(key, result.getFirst())) - .ifRight(partial -> LOGGER.error("Failed to parse data json for {} due to: {}", key, partial.message())); - } - - this.data = newMap; - LOGGER.info("Data loader for {} loaded {} jsons", this.folderName, this.data.size()); - } - - /** - * This should be called at most once, during construction of your mod (static init of your main mod class is fine) - * Calling this method automatically subscribes a packet-sender to {@link OnDatapackSyncEvent}. - * - * @param the packet type that will be sent on the given channel - * @param channel The networking channel of your mod - * @param packetFactory A packet constructor or factory method that converts the given map to a packet object to send on the given channel - * - * @return this manager object - */ - public CodecJsonDataManager subscribeAsSyncable(final SimpleChannel channel, final Function, PACKET> packetFactory) { - MinecraftForge.EVENT_BUS.addListener(this.getDatapackSyncListener(channel, packetFactory)); - return this; - } - - /** Generate an event listener function for the on-datapack-sync event **/ - private Consumer getDatapackSyncListener(final SimpleChannel channel, final Function, PACKET> packetFactory) { - return event -> { - ServerPlayer player = event.getPlayer(); - PACKET packet = packetFactory.apply(this.data); - PacketDistributor.PacketTarget target = player == null - ? PacketDistributor.ALL.noArg() - : PacketDistributor.PLAYER.with(() -> player); - channel.send(target, packet); - }; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/datapack/MergeableCodecDataManager.java b/src/main/java/com/github/manasmods/manascore/api/datapack/MergeableCodecDataManager.java deleted file mode 100644 index f94f46fb..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/datapack/MergeableCodecDataManager.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.datapack; - -import com.google.common.collect.ImmutableMap; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.mojang.serialization.Codec; -import com.mojang.serialization.JsonOps; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.server.packs.resources.SimplePreparableReloadListener; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.OnDatapackSyncEvent; -import net.minecraftforge.network.PacketDistributor; -import net.minecraftforge.network.simple.SimpleChannel; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * Generic data loader for Codec-parsable data. - * This works best if initialized during your mod's construction. - * After creating the manager, subscribeAsSyncable can optionally be called on it to subscribe the manager - * to the forge events necessary for syncing datapack data to clients. - * - * @param The type of the objects that the codec is parsing jsons as - * @param The type of the object we get after merging the parsed objects. Can be the same as RAW - */ -@AvailableSince("1.0.0.0") -public class MergeableCodecDataManager extends SimplePreparableReloadListener> { - private static final Logger LOGGER = LogManager.getLogger(); - - /** ".json" **/ - protected static final String JSON_EXTENSION = ".json"; - /** 5 **/ - protected static final int JSON_EXTENSION_LENGTH = JSON_EXTENSION.length(); - - /** the loaded data **/ - protected Map data = new HashMap<>(); - - private final String folderName; - private final Codec codec; - private final Function, FINE> merger; - - /** - * Initialize a data manager with the given folder name, codec, and merger - * - * @param folderName The name of the folder to load data from, - * e.g. "cheeses" would load data from "data/modid/cheeses" for all modids. - * Can include subfolders, e.g. "cheeses/sharp" - * @param codec A codec that will be used to parse jsons. See drullkus's codec primer for help on creating these. - * @param merger A merging function that uses a list of java-objects-that-were-parsed-from-json to create a final object. - * The list contains all successfully-parsed objects with the same ID from all mods and datapacks. - * (for a json located at "data/modid/folderName/name.json", the object's ID is "modid:name") - * As an example, consider vanilla's Tags: mods or datapacks can define tags with the same modid:name id, - * and then all tag jsons defined with the same ID are merged additively into a single set of items, etc - */ - public MergeableCodecDataManager(final String folderName, Codec codec, final Function, FINE> merger) { - this.folderName = folderName; - this.codec = codec; - this.merger = merger; - } - - /** - * @return The immutable map of data entries - */ - public Map getData() { - return this.data; - } - - /** Off-thread processing (can include reading files from hard drive) **/ - @Override - protected Map prepare(final ResourceManager resourceManager, final ProfilerFiller profiler) { - LOGGER.info("Beginning loading of data for data loader: {}", this.folderName); - final Map map = new HashMap<>(); - - Map> resourceStacks = new HashMap<>(); - resourceManager.listResources(this.folderName, id -> id.toDebugFileName().endsWith(JSON_EXTENSION)).forEach((location, resource) -> { - resourceStacks.put(location, resourceManager.getResourceStack(location)); - }); - - for (var entry : resourceStacks.entrySet()) { - List raws = new ArrayList<>(); - ResourceLocation fullId = entry.getKey(); - String fullPath = fullId.getPath(); // includes folderName/ and .json - ResourceLocation id = new ResourceLocation( - fullId.getNamespace(), - fullPath.substring(this.folderName.length() + 1, fullPath.length() - JSON_EXTENSION_LENGTH)); - - for (Resource resource : entry.getValue()) { - try (Reader reader = new InputStreamReader(resource.open())) { - JsonElement jsonElement = JsonParser.parseReader(reader); - this.codec.parse(JsonOps.INSTANCE, jsonElement) - .resultOrPartial(errorMsg -> LOGGER.error("Error deserializing json {} in folder {} from pack {}: {}", id, this.folderName, resource.sourcePackId(), errorMsg)) - .ifPresent(raws::add); - } catch (Exception e) { - LOGGER.error(String.format(Locale.ENGLISH, "Error reading resource %s in folder %s from pack %s: ", id, this.folderName, resource.sourcePackId()), e); - } - } - map.put(id, merger.apply(raws)); - } - - LOGGER.info("Data loader for {} loaded {} finalized objects", this.folderName, this.data.size()); - return ImmutableMap.copyOf(map); - } - - /** Main-thread processing, runs after prepare concludes **/ - @Override - protected void apply(final Map processedData, final ResourceManager resourceManager, final ProfilerFiller profiler) { - // now that we're on the main thread, we can finalize the data - this.data = processedData; - } - - /** - * This should be called at most once, during construction of your mod - * Calling this method automatically subscribes a packet-sender to {@link OnDatapackSyncEvent}. - * - * @param the packet type that will be sent on the given channel - * @param channel The networking channel of your mod - * @param packetFactory A packet constructor or factory method that converts the given map to a packet object to send on the given channel - * - * @return this manager object - */ - public MergeableCodecDataManager subscribeAsSyncable(final SimpleChannel channel, - final Function, PACKET> packetFactory) { - MinecraftForge.EVENT_BUS.addListener(this.getDatapackSyncListener(channel, packetFactory)); - return this; - } - - /** Generate an event listener function for the on-datapack-sync event **/ - private Consumer getDatapackSyncListener(final SimpleChannel channel, final Function, PACKET> packetFactory) { - return event -> { - ServerPlayer player = event.getPlayer(); - PACKET packet = packetFactory.apply(this.data); - PacketDistributor.PacketTarget target = player == null - ? PacketDistributor.ALL.noArg() - : PacketDistributor.PLAYER.with(() -> player); - channel.send(target, packet); - }; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/datapack/package-info.java b/src/main/java/com/github/manasmods/manascore/api/datapack/package-info.java deleted file mode 100644 index fd8a0810..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/datapack/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.datapack; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/permission/PermissionHelper.java b/src/main/java/com/github/manasmods/manascore/api/permission/PermissionHelper.java deleted file mode 100644 index 5ca17757..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/permission/PermissionHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.permission; - -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import lombok.RequiredArgsConstructor; -import net.minecraft.commands.CommandSourceStack; -import net.minecraftforge.server.permission.PermissionAPI; -import net.minecraftforge.server.permission.nodes.PermissionNode; -import net.minecraftforge.server.permission.nodes.PermissionTypes; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -@RequiredArgsConstructor -public class PermissionHelper { - private final String modId; - - public boolean hasPermissionOrIsConsole(CommandSourceStack sourceStack, PermissionNode node) { - try { - return PermissionAPI.getPermission(sourceStack.getPlayerOrException(), node); - } catch (CommandSyntaxException e) { - return true; - } - } - - public boolean hasPermissonAndIsPlayer(CommandSourceStack sourceStack, PermissionNode node) { - try { - return PermissionAPI.getPermission(sourceStack.getPlayerOrException(), node); - } catch (CommandSyntaxException e) { - return false; - } - } - - public PermissionNode createNode(String node, boolean allowConsole, int permissionLevel) { - return new PermissionNode<>(modId, node, PermissionTypes.BOOLEAN, (player, playerUUID, context) -> { - if (player == null) return allowConsole; - return player.hasPermissions(permissionLevel); - }); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/permission/package-info.java b/src/main/java/com/github/manasmods/manascore/api/permission/package-info.java deleted file mode 100644 index cc0f9597..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/permission/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.permission; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/tab/AbstractInventoryTab.java b/src/main/java/com/github/manasmods/manascore/api/tab/AbstractInventoryTab.java deleted file mode 100644 index a5a0c008..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/tab/AbstractInventoryTab.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.tab; - -import com.github.manasmods.manascore.tab.IInventoryTab; -import com.github.manasmods.manascore.tab.TabPosition; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.network.chat.Component; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -public abstract class AbstractInventoryTab extends Button implements IInventoryTab { - protected static final int TAB_WIDTH = 28; - protected static final int TAB_HEIGHT = 32; - protected final Minecraft minecraft; - @Getter - @Setter - private TabPosition position; - - public AbstractInventoryTab(Tooltip tooltip) { - super(new Builder(Component.empty(), pButton -> { - AbstractInventoryTab tab = (AbstractInventoryTab) pButton; - tab.sendOpenContainerPacket(); - }) - .pos(0, 0) - .size(TAB_WIDTH, TAB_HEIGHT) - .tooltip(tooltip) - ); - this.minecraft = Minecraft.getInstance(); - } - - @Override - public void renderButton(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) { - RenderSystem.setShaderColor(1f, 1f, 1f, this.alpha); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.enableDepthTest(); - - this.renderBg(pPoseStack, minecraft, pMouseX, pMouseY); - this.renderIcon(pPoseStack, pMouseX, pMouseY, pPartialTick); - } - - protected abstract void renderIcon(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick); - - @Override - protected void renderBg(PoseStack pPoseStack, Minecraft pMinecraft, int pMouseX, int pMouseY) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); - this.position.bindTexture(); - float yOffset = this.isCurrent() ? TAB_HEIGHT : 0F; - blit(pPoseStack, this.getX(), this.getY(), TAB_WIDTH, TAB_HEIGHT, 0F, yOffset, TAB_WIDTH, TAB_HEIGHT - 1, TAB_WIDTH, TAB_HEIGHT * 2); - } - - public boolean isCurrent() { - return this.isCurrentScreen().test(minecraft.screen); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/tab/InventoryTabs.java b/src/main/java/com/github/manasmods/manascore/api/tab/InventoryTabs.java deleted file mode 100644 index 72439fed..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/tab/InventoryTabs.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.tab; - -import com.github.manasmods.manascore.api.tab.annotation.ScreenForTab; -import com.github.manasmods.manascore.tab.InventoryTabRegistry; -import net.minecraft.client.gui.screens.Screen; -import org.jetbrains.annotations.ApiStatus.AvailableSince; -import org.jetbrains.annotations.ApiStatus.NonExtendable; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Map; - -@AvailableSince("1.0.0.0") -@NonExtendable -public final class InventoryTabs { - /** - * Registers a {@link AbstractInventoryTab} instance to the Inventory Tab Registry. - */ - public static void registerTab(AbstractInventoryTab tab) { - InventoryTabRegistry.register(tab); - } - - public static Collection getRegisteredTabs() { - return InventoryTabRegistry.getValues(); - } - - public static Map getRegistryEntries() { - return InventoryTabRegistry.getEntries(); - } - - /** - * Returns the registered {@link AbstractInventoryTab} Object or null. - * The given {@link Screen} has be annotated with @{@link ScreenForTab} annotation to be able to find the {@link AbstractInventoryTab} in the registry. - */ - @Nullable - public static AbstractInventoryTab findByScreen(final Screen screen) { - return InventoryTabRegistry.findByScreen(screen); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/tab/annotation/ScreenForTab.java b/src/main/java/com/github/manasmods/manascore/api/tab/annotation/ScreenForTab.java deleted file mode 100644 index 14207b4a..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/tab/annotation/ScreenForTab.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.tab.annotation; - -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AvailableSince("1.0.0.0") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ScreenForTab { - Class value(); -} diff --git a/src/main/java/com/github/manasmods/manascore/api/tab/annotation/package-info.java b/src/main/java/com/github/manasmods/manascore/api/tab/annotation/package-info.java deleted file mode 100644 index d7c09eb9..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/tab/annotation/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.tab.annotation; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/tab/package-info.java b/src/main/java/com/github/manasmods/manascore/api/tab/package-info.java deleted file mode 100644 index 2a449790..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/tab/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.tab; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/util/ItemComparator.java b/src/main/java/com/github/manasmods/manascore/api/util/ItemComparator.java deleted file mode 100644 index 813def1d..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/util/ItemComparator.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.github.manasmods.manascore.api.util; - -import net.minecraft.world.item.Item; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiFunction; - -@AvailableSince("1.0.2.0") -public class ItemComparator { - private final BiFunction[] tests; - - private ItemComparator(BiFunction[] tests) { - this.tests = tests; - } - - public int compare(T object1, T object2) { - for (BiFunction test : this.tests) { - int testResult = test.apply(object1, object2); - if (testResult != 0) return testResult; - } - - return 0; - } - - public static class Builder { - private final List> tests = new ArrayList<>(); - - private Builder(BiFunction initialTest) { - tests.add(initialTest); - } - - public static Builder first(BiFunction initialTest) { - return new Builder(initialTest); - } - - public static Builder firstInstancesOf(Class type) { - return new Builder<>((t, t2) -> { - if (type.isInstance(t) && !type.isInstance(t2)) return -1; - if (type.isInstance(t2) && !type.isInstance(t)) return 1; - return 0; - }); - } - - public Builder then(BiFunction test) { - tests.add(test); - return this; - } - - public Builder thenInstancesOf(Class type) { - tests.add((t, t2) -> { - if (type.isInstance(t) && !type.isInstance(t2)) return -1; - if (type.isInstance(t2) && !type.isInstance(t)) return 1; - return 0; - }); - - return this; - } - - public ItemComparator build() { - return new ItemComparator<>(this.tests.toArray(BiFunction[]::new)); - } - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/util/MethodsReturnNonnullByDefault.java b/src/main/java/com/github/manasmods/manascore/api/util/MethodsReturnNonnullByDefault.java deleted file mode 100644 index b52979fd..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/util/MethodsReturnNonnullByDefault.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.manasmods.manascore.api.util; - -import javax.annotation.Nonnull; -import javax.annotation.meta.TypeQualifierDefault; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Nonnull -@TypeQualifierDefault(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface MethodsReturnNonnullByDefault { -} diff --git a/src/main/java/com/github/manasmods/manascore/api/util/ReflectionUtils.java b/src/main/java/com/github/manasmods/manascore/api/util/ReflectionUtils.java deleted file mode 100644 index bea33e79..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/util/ReflectionUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.util; - -import lombok.extern.log4j.Log4j2; -import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.Nullable; - -import java.lang.reflect.Field; -import java.util.Objects; - -@Log4j2 -public class ReflectionUtils { - @Nullable - public static RegistryObject getRegistryObjectFromField(AnnotationData annotationData, Field field, Class type) { - Objects.requireNonNull(type); - try { - field.setAccessible(true); - //noinspection unchecked - return (RegistryObject) field.get(null); // no check due to catch below - } catch (IllegalAccessException e) { - log.error("Could not load data from field {} in class {}", field.getName(), annotationData.clazz().getClassName()); - log.throwing(e); - } catch (ClassCastException e) { - log.error("Could not cast field {} in class {} to RegistryObject<{}> type", field.getName(), annotationData.clazz().getClassName(), type.getName()); - log.throwing(e); - } - - return null; - } - - @Nullable - public static DeferredRegister getDeferredRegisterFromField(AnnotationData annotationData, Field field, Class type) { - Objects.requireNonNull(type); - try { - field.setAccessible(true); - //noinspection unchecked - return (DeferredRegister) field.get(null); // no check due to catch below - } catch (IllegalAccessException e) { - log.error("Could not load data from field {} in class {}", field.getName(), annotationData.clazz().getClassName()); - log.throwing(e); - } catch (ClassCastException e) { - log.error("Could not cast field {} in class {} to RegistryObject<{}> type", field.getName(), annotationData.clazz().getClassName(), type.getName()); - log.throwing(e); - } - return null; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/util/StreamUtils.java b/src/main/java/com/github/manasmods/manascore/api/util/StreamUtils.java deleted file mode 100644 index c328f0cc..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/util/StreamUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.util; - -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; -import java.util.function.Predicate; - -public class StreamUtils { - public static Predicate distinctBy(Function keyExtractor) { - Set seen = ConcurrentHashMap.newKeySet(); - return t -> seen.add(keyExtractor.apply(t)); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/util/package-info.java b/src/main/java/com/github/manasmods/manascore/api/util/package-info.java deleted file mode 100644 index 057e7dca..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/util/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.util; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeBuilder.java b/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeBuilder.java deleted file mode 100644 index 1b50e726..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeBuilder.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.world.gen.biome; - -import lombok.RequiredArgsConstructor; -import lombok.Setter; -import net.minecraft.sounds.Music; -import net.minecraft.util.Mth; -import net.minecraft.world.level.biome.AmbientMoodSettings; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeSpecialEffects; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -import java.awt.Color; -import java.util.Optional; - -@AvailableSince("2.0.0.0") -@SuppressWarnings("unused") -@RequiredArgsConstructor -public class BiomeBuilder { - private final BiomeGenerationSettingsHelper generationSettingsHelper; - private final MobSpawnHelper mobSpawnHelper; - private final Biome.BiomeBuilder biomeBuilder = new Biome.BiomeBuilder(); - @Setter - private Biome.Precipitation rainType = Biome.Precipitation.RAIN; - private float temperature = 0.8F; - private float downfall = 0.4F; - private int waterColor = 4159204; - private int waterFogColor = 329011; - private int fogColor = 12638463; - private Music backgroundMusic = null; - private Optional grassColorOverride = Optional.empty(); - private BiomeSpecialEffects.GrassColorModifier grassColorModifier = BiomeSpecialEffects.GrassColorModifier.NONE; - - public BiomeBuilder grassColor(Color color) { - grassColorOverride = Optional.of(color.getRGB()); - return this; - } - - public BiomeBuilder grassModifier(BiomeSpecialEffects.GrassColorModifier grassColorModifier) { - this.grassColorModifier = grassColorModifier; - return this; - } - - public BiomeBuilder downfall(float downfall) { - this.downfall = downfall; - return this; - } - - public BiomeBuilder waterColor(Color color) { - this.waterColor = color.getRGB(); - return this; - } - - public BiomeBuilder waterFogColor(Color color) { - this.waterFogColor = color.getRGB(); - return this; - } - - public BiomeBuilder fogColor(Color color) { - this.fogColor = color.getRGB(); - return this; - } - - public BiomeBuilder backgroundMusic(Music music) { - this.backgroundMusic = music; - return this; - } - - public BiomeBuilder temperature(float temperature) { - this.temperature = temperature; - return this; - } - - public BiomeBuilder rain(Biome.Precipitation rainType) { - this.rainType = rainType; - return this; - } - - public Biome build() { - BiomeSpecialEffects.Builder specialEffects = new BiomeSpecialEffects.Builder() - .waterColor(waterColor) - .waterFogColor(waterFogColor) - .fogColor(fogColor) - .skyColor(calculateSkyColor(temperature)) - .ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS) - .backgroundMusic(backgroundMusic) - .grassColorModifier(grassColorModifier); - - this.grassColorOverride.ifPresent(specialEffects::grassColorOverride); - - return biomeBuilder - .precipitation(rainType) - .temperature(temperature) - .downfall(downfall) - .specialEffects(specialEffects.build()) - .mobSpawnSettings(mobSpawnHelper.finishMobSpawnSettings()) - .generationSettings(generationSettingsHelper.finishBiomeSettings()) - .build(); - } - - public static BiomeBuilder forest(BiomeGenerationSettingsHelper generationSettingsHelper, MobSpawnHelper mobSpawnHelper) { - return new BiomeBuilder(generationSettingsHelper, mobSpawnHelper) - .temperature(0.7F) - .downfall(0.8F); - } - - private static int calculateSkyColor(float p_194844_) { - float $$1 = p_194844_ / 3.0F; - $$1 = Mth.clamp($$1, -1.0F, 1.0F); - return Mth.hsvToRgb(0.62222224F - $$1 * 0.05F, 0.5F + $$1 * 0.1F, 1.0F); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeGenerationSettingsHelper.java b/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeGenerationSettingsHelper.java deleted file mode 100644 index 221a4bba..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/BiomeGenerationSettingsHelper.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.world.gen.biome; - -import lombok.RequiredArgsConstructor; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderGetter; -import net.minecraft.world.level.biome.BiomeGenerationSettings; -import net.minecraft.world.level.levelgen.GenerationStep; -import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; -import net.minecraft.world.level.levelgen.placement.PlacedFeature; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -@SuppressWarnings({"unused", "UnusedReturnValue"}) -@RequiredArgsConstructor -public class BiomeGenerationSettingsHelper { - private final BiomeGenerationSettings.Builder biomeGenSettings; - - public BiomeGenerationSettingsHelper(HolderGetter pPlacedFeatures, HolderGetter> pWorldCarvers) { - this.biomeGenSettings = new BiomeGenerationSettings.Builder(pPlacedFeatures, pWorldCarvers); - } - - public static BiomeGenerationSettingsHelper from(BiomeGenerationSettings.Builder biomeGenSettings) { - return new BiomeGenerationSettingsHelper(biomeGenSettings); - } - - public BiomeGenerationSettings.Builder toBuilder() { - return biomeGenSettings; - } - - public BiomeGenerationSettingsHelper apply(DefaultBiomeFeature defaultBiomeFeature) { - defaultBiomeFeature.apply(this.biomeGenSettings); - return this; - } - - public BiomeGenerationSettingsHelper apply(DefaultBiomeFeature defaultBiomeFeature, DefaultBiomeFeature... defaultBiomeFeatures) { - apply(defaultBiomeFeature); - - for (DefaultBiomeFeature feature : defaultBiomeFeatures) { - apply(feature); - } - - return this; - } - - public BiomeGenerationSettingsHelper addCarver(GenerationStep.Carving pCarving, Holder> pCarver) { - biomeGenSettings.addCarver(pCarving, pCarver); - return this; - } - - public BiomeGenerationSettingsHelper addFeature(GenerationStep.Decoration generationStep, Holder feature) { - biomeGenSettings.addFeature(generationStep, feature); - return this; - } - - public BiomeGenerationSettings finishBiomeSettings() { - return this.biomeGenSettings.build(); - } - - - @FunctionalInterface - public interface DefaultBiomeFeature { - void apply(BiomeGenerationSettings.Builder builder); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/MobSpawnHelper.java b/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/MobSpawnHelper.java deleted file mode 100644 index aeb271a8..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/MobSpawnHelper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.api.world.gen.biome; - -import lombok.RequiredArgsConstructor; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.level.biome.MobSpawnSettings; -import org.jetbrains.annotations.ApiStatus.AvailableSince; - -@AvailableSince("1.0.0.0") -@SuppressWarnings({"unused", "UnusedReturnValue"}) -@RequiredArgsConstructor -public class MobSpawnHelper { - private final MobSpawnSettings.Builder mobSpawnSettings; - - public MobSpawnHelper() { - mobSpawnSettings = new MobSpawnSettings.Builder(); - } - - public static MobSpawnHelper from(MobSpawnSettings.Builder mobSpawnSettings) { - return new MobSpawnHelper(mobSpawnSettings); - } - - public MobSpawnSettings.Builder toBuilder() { - return mobSpawnSettings; - } - - public MobSpawnSettings finishMobSpawnSettings() { - return mobSpawnSettings.build(); - } - - public MobSpawnHelper apply(DefaultBiomeMobSpawnSettings defaultBiomeFeature) { - defaultBiomeFeature.apply(this.mobSpawnSettings); - return this; - } - - public MobSpawnHelper apply(DefaultBiomeMobSpawnSettings defaultBiomeFeature, DefaultBiomeMobSpawnSettings... defaultBiomeFeatures) { - apply(defaultBiomeFeature); - - for (DefaultBiomeMobSpawnSettings feature : defaultBiomeFeatures) { - apply(feature); - } - - return this; - } - - public MobSpawnHelper addSpawn(MobCategory category, EntityType entityType, int weight, int minCount, int maxCount) { - mobSpawnSettings.addSpawn(category, new MobSpawnSettings.SpawnerData(entityType, weight, minCount, maxCount)); - return this; - } - - @FunctionalInterface - public interface DefaultBiomeMobSpawnSettings { - void apply(MobSpawnSettings.Builder builder); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/package-info.java b/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/package-info.java deleted file mode 100644 index c249b373..00000000 --- a/src/main/java/com/github/manasmods/manascore/api/world/gen/biome/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.api.world.gen.biome; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributeHandler.java b/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributeHandler.java deleted file mode 100644 index 121914a8..00000000 --- a/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributeHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.attribute; - -import com.github.manasmods.manascore.ManasCore; -import net.minecraft.core.BlockPos; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.event.entity.EntityAttributeModificationEvent; -import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -@Mod.EventBusSubscriber(modid = ManasCore.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) -public class ManasCoreAttributeHandler { - - @SubscribeEvent - public static void applyAttributesToEntities(final EntityAttributeModificationEvent e) { - e.add(EntityType.PLAYER, ManasCoreAttributes.JUMP_POWER.get()); - } - - @SubscribeEvent - public static void modifyJumpPower(final LivingJumpEvent e) { - if (e.getEntity().getAttribute(ManasCoreAttributes.JUMP_POWER.get()) == null) return; - - final LivingEntity entity = e.getEntity(); - final BlockPos entityPos = entity.blockPosition(); - //Calculation - double baseJumpPower = entity.getAttribute(ManasCoreAttributes.JUMP_POWER.get()).getValue(); - float blockModifier0 = entity.level.getBlockState(entityPos).getBlock().getJumpFactor(); - float blockModifier1 = entity.level.getBlockState(new BlockPos(entityPos.getX(), entity.getBoundingBox().minY - 0.5000001D, entityPos.getZ())).getBlock().getJumpFactor(); - double blockModifier = (double) blockModifier0 == 1.0D ? blockModifier1 : blockModifier0; - double jumpPower = baseJumpPower * blockModifier; - final double verticalVelocity = jumpPower + entity.getJumpBoostPower(); - //Apply velocity - Vec3 vec3 = entity.getDeltaMovement(); - entity.setDeltaMovement(vec3.x, verticalVelocity, vec3.z); - if (entity.isSprinting()) { - float f = entity.getYRot() * ((float) Math.PI / 180F); - entity.setDeltaMovement(entity.getDeltaMovement().add(-Mth.sin(f) * 0.2F, 0.0D, Mth.cos(f) * 0.2F)); - } - entity.hasImpulse = true; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributes.java b/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributes.java deleted file mode 100644 index 8858c91f..00000000 --- a/src/main/java/com/github/manasmods/manascore/attribute/ManasCoreAttributes.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.attribute; - -import com.github.manasmods.manascore.ManasCore; -import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraft.world.entity.ai.attributes.RangedAttribute; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -public class ManasCoreAttributes { - private static final DeferredRegister registry = DeferredRegister.create(ForgeRegistries.ATTRIBUTES, ManasCore.MOD_ID); - public static final RegistryObject JUMP_POWER = registry.register("jump_power", () -> new RangedAttribute("manascore.attribute.max_aura.name", 0.42, 0, 800).setSyncable(true)); - - public static void register(final IEventBus modEventBus) { - registry.register(modEventBus); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/attribute/package-info.java b/src/main/java/com/github/manasmods/manascore/attribute/package-info.java deleted file mode 100644 index e612f62f..00000000 --- a/src/main/java/com/github/manasmods/manascore/attribute/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.attribute; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/client/gui/widget/InventoryTabSwitcherWidget.java b/src/main/java/com/github/manasmods/manascore/client/gui/widget/InventoryTabSwitcherWidget.java deleted file mode 100644 index 2f0fce48..00000000 --- a/src/main/java/com/github/manasmods/manascore/client/gui/widget/InventoryTabSwitcherWidget.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.client.gui.widget; - -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import com.github.manasmods.manascore.core.AbstractContainerScreenAccessor; -import com.github.manasmods.manascore.tab.TabPosition; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.Renderable; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.network.chat.Component; -import org.jetbrains.annotations.ApiStatus.Internal; -import org.lwjgl.glfw.GLFW; - -import java.awt.*; -import java.util.TreeMap; - -@Internal -public class InventoryTabSwitcherWidget extends GuiComponent implements Renderable, GuiEventListener { - private int page = 1; - private final int maxPages; - private final Button prevButton, nextButton; - private final TreeMap tabs = new TreeMap<>(); - private final AbstractContainerScreen parent; - - public InventoryTabSwitcherWidget(AbstractContainerScreen parent, int maxPages) { - this.parent = parent; - this.maxPages = maxPages; - this.prevButton = Button.builder(Component.literal("<"), pButton -> { - page = Math.max(page - 1, 1); - updateTabs(); - }) - .pos(this.parent.getGuiLeft() - 20 - 2, this.parent.getGuiTop() - 20 - 2) - .size(20, 20) - .build(); - this.nextButton = Button.builder(Component.literal(">"), pButton -> { - page = Math.min(page + 1, this.maxPages); - updateTabs(); - }) - .pos(parent.getGuiLeft() + ((AbstractContainerScreenAccessor) parent).getImageWidth() + 2, this.parent.getGuiTop() - 20 - 2) - .size(20, 20) - .build(); - } - - @Override - public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) { - if (page > 1) { - this.prevButton.render(poseStack, mouseX, mouseY, partialTicks); - } - - if (maxPages > 1 && page != maxPages) { - this.nextButton.render(poseStack, mouseX, mouseY, partialTicks); - } - - if (maxPages > 1) { - drawCenteredString(poseStack, Minecraft.getInstance().font, this.page + " / " + this.maxPages, this.parent.width / 2, 2, Color.WHITE.getRGB()); - } - - this.tabs.values() - .stream() - .filter(AbstractInventoryTab::isActive) - .forEach(abstractInventoryTab -> abstractInventoryTab.render(poseStack, mouseX, mouseY, partialTicks)); - } - - public void updateTabs() { - this.tabs.forEach((integer, widget) -> { - int tabScreenIndex = integer; - while (tabScreenIndex > 12) { - tabScreenIndex -= 12; - } - - final int yOffset = 4; - final int xOffset = 1; - - switch (tabScreenIndex) { - case 1 -> { - widget.setX(parent.getGuiLeft()); - widget.setY(parent.getGuiTop() - widget.getHeight() + yOffset); - widget.setPosition(TabPosition.LEFT_TOP); - } - case 2, 3 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 1) + (xOffset * tabScreenIndex - 1) + 1); - widget.setY(parent.getGuiTop() - widget.getHeight() + yOffset); - widget.setPosition(TabPosition.TOP); - } - case 4, 5 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 1) + (xOffset * tabScreenIndex - 1) + 2); - widget.setY(parent.getGuiTop() - widget.getHeight() + yOffset); - widget.setPosition(TabPosition.TOP); - } - case 6 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 1) + (xOffset * tabScreenIndex - 1) + 3); - widget.setY(parent.getGuiTop() - widget.getHeight() + yOffset); - widget.setPosition(TabPosition.RIGHT_TOP); - } - case 7 -> { - widget.setX(parent.getGuiLeft()); - widget.setY(parent.getGuiTop() + ((AbstractContainerScreenAccessor) parent).getImageWidth() - yOffset - 11); - widget.setPosition(TabPosition.LEFT_BOT); - } - case 8, 9 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 7) + (xOffset * tabScreenIndex - 7) + 1); - widget.setY(parent.getGuiTop() + ((AbstractContainerScreenAccessor) parent).getImageWidth() - yOffset - 11); - widget.setPosition(TabPosition.BOT); - } - case 10, 11 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 7) + (xOffset * tabScreenIndex - 7) + 2); - widget.setY(parent.getGuiTop() + ((AbstractContainerScreenAccessor) parent).getImageWidth() - yOffset - 11); - widget.setPosition(TabPosition.BOT); - } - case 12 -> { - widget.setX(parent.getGuiLeft() + widget.getWidth() * (tabScreenIndex - 7) + (xOffset * tabScreenIndex - 7) + 3); - widget.setY(parent.getGuiTop() + ((AbstractContainerScreenAccessor) parent).getImageWidth() - yOffset - 11); - widget.setPosition(TabPosition.RIGHT_BOT); - } - } - - boolean isVisible = Math.ceil(integer / 12F) == this.page; - widget.active = isVisible; - }); - } - - public void addUpdateListener(int index, AbstractInventoryTab widget) { - tabs.put(index, widget); - updateTabs(); - } - - @Override - public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) { - if (pButton == GLFW.GLFW_MOUSE_BUTTON_LEFT) { - this.tabs.values() - .stream() - .filter(AbstractInventoryTab::isActive) - .forEach(abstractInventoryTab -> abstractInventoryTab.mouseClicked(pMouseX, pMouseY, pButton)); - if (this.prevButton.isMouseOver(pMouseX, pMouseY)) this.prevButton.mouseClicked(pMouseX, pMouseY, pButton); - if (this.nextButton.isMouseOver(pMouseX, pMouseY)) this.nextButton.mouseClicked(pMouseX, pMouseY, pButton); - } - return false; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/client/gui/widget/package-info.java b/src/main/java/com/github/manasmods/manascore/client/gui/widget/package-info.java deleted file mode 100644 index ec9ceb0e..00000000 --- a/src/main/java/com/github/manasmods/manascore/client/gui/widget/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.client.gui.widget; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/client/keybinding/KeybindingRegistry.java b/src/main/java/com/github/manasmods/manascore/client/keybinding/KeybindingRegistry.java deleted file mode 100644 index 7b21dd31..00000000 --- a/src/main/java/com/github/manasmods/manascore/client/keybinding/KeybindingRegistry.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.github.manasmods.manascore.client.keybinding; - -import com.github.manasmods.manascore.ManasCore; -import com.github.manasmods.manascore.api.client.keybinding.ManasKeybinding; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.client.event.RegisterKeyMappingsEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.jetbrains.annotations.ApiStatus.Internal; - -import java.util.ArrayList; -import java.util.Arrays; - -@Internal -@Mod.EventBusSubscriber(modid = ManasCore.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) -public class KeybindingRegistry { - private static final ArrayList keybindings = new ArrayList<>(); - - @SubscribeEvent - public static void register(final RegisterKeyMappingsEvent e) { - keybindings.forEach(e::register); - } - - public static void register(ManasKeybinding... keybinding) { - keybindings.addAll(Arrays.asList(keybinding)); - } - - public static void checkKeybindings(final InputEvent.Key e) { - keybindings.forEach(keybinding -> { - if (keybinding.isDown()) { - keybinding.getAction().onPress(); - ManasCore.getLogger().debug("Pressed Keybinding {}", keybinding.getTranslatedKeyMessage().getString()); - } - }); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/client/keybinding/ManasKeybindingHandler.java b/src/main/java/com/github/manasmods/manascore/client/keybinding/ManasKeybindingHandler.java deleted file mode 100644 index 9bed6036..00000000 --- a/src/main/java/com/github/manasmods/manascore/client/keybinding/ManasKeybindingHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.manasmods.manascore.client.keybinding; - -import com.github.manasmods.manascore.ManasCore; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -@Mod.EventBusSubscriber(modid = ManasCore.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) -public class ManasKeybindingHandler { - @SubscribeEvent - public static void onKeyInput(final InputEvent.Key e) { - KeybindingRegistry.checkKeybindings(e); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/client/keybinding/package-info.java b/src/main/java/com/github/manasmods/manascore/client/keybinding/package-info.java deleted file mode 100644 index 426df4de..00000000 --- a/src/main/java/com/github/manasmods/manascore/client/keybinding/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.client.keybinding; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/core/AbstractContainerScreenAccessor.java b/src/main/java/com/github/manasmods/manascore/core/AbstractContainerScreenAccessor.java deleted file mode 100644 index d49df9b9..00000000 --- a/src/main/java/com/github/manasmods/manascore/core/AbstractContainerScreenAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.manasmods.manascore.core; - -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import org.jetbrains.annotations.ApiStatus.Internal; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Internal -@Mixin(AbstractContainerScreen.class) -public interface AbstractContainerScreenAccessor { - @Accessor - int getImageWidth(); -} diff --git a/src/main/java/com/github/manasmods/manascore/core/BlockLootSubProviderAccessor.java b/src/main/java/com/github/manasmods/manascore/core/BlockLootSubProviderAccessor.java deleted file mode 100644 index d61cfd5c..00000000 --- a/src/main/java/com/github/manasmods/manascore/core/BlockLootSubProviderAccessor.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.github.manasmods.manascore.core; - -import net.minecraft.data.loot.BlockLootSubProvider; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(BlockLootSubProvider.class) -public interface BlockLootSubProviderAccessor { - - @Accessor("NORMAL_LEAVES_SAPLING_CHANCES") - static float[] getNormalLeavesSaplingChances() { - throw new AssertionError("Could not access NORMAL_LEAVES_SAPLING_CHANCES in Block Loot class"); - } - - @Accessor("NORMAL_LEAVES_STICK_CHANCES") - static float[] getNormalStickChances() { - throw new AssertionError("Could not access NORMAL_LEAVES_SAPLING_CHANCES in Block Loot class"); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/core/ShapedRecipeBuilderAccessor.java b/src/main/java/com/github/manasmods/manascore/core/ShapedRecipeBuilderAccessor.java deleted file mode 100644 index 64b3073d..00000000 --- a/src/main/java/com/github/manasmods/manascore/core/ShapedRecipeBuilderAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.manasmods.manascore.core; - -import net.minecraft.advancements.Advancement; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import org.jetbrains.annotations.ApiStatus.Internal; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Internal -@Mixin(ShapedRecipeBuilder.class) -public interface ShapedRecipeBuilderAccessor { - @Accessor - Advancement.Builder getAdvancement(); -} diff --git a/src/main/java/com/github/manasmods/manascore/core/VanillaBlockLootAccessor.java b/src/main/java/com/github/manasmods/manascore/core/VanillaBlockLootAccessor.java deleted file mode 100644 index 6b549bbd..00000000 --- a/src/main/java/com/github/manasmods/manascore/core/VanillaBlockLootAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.manasmods.manascore.core; - -import net.minecraft.data.loot.packs.VanillaBlockLoot; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(VanillaBlockLoot.class) -public interface VanillaBlockLootAccessor { - @Accessor("JUNGLE_LEAVES_SAPLING_CHANGES") - static float[] getJungleLeavesSaplingChances() { - throw new AssertionError("Could not access NORMAL_LEAVES_SAPLING_CHANCES in Block Loot class"); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/package-info.java b/src/main/java/com/github/manasmods/manascore/package-info.java deleted file mode 100644 index 57ed5894..00000000 --- a/src/main/java/com/github/manasmods/manascore/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/com/github/manasmods/manascore/tab/IInventoryTab.java b/src/main/java/com/github/manasmods/manascore/tab/IInventoryTab.java deleted file mode 100644 index 75cdb1a6..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/IInventoryTab.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import net.minecraft.client.gui.screens.Screen; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.jetbrains.annotations.ApiStatus.Internal; - -import java.util.function.Predicate; - -@Internal -public interface IInventoryTab { - void sendOpenContainerPacket(); - - @OnlyIn(Dist.CLIENT) - default Predicate isCurrentScreen() { - return screen -> { - AbstractInventoryTab tab = InventoryTabRegistry.findByScreen(screen); - return tab != null && tab.equals(this); - }; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/InventoryTabHandler.java b/src/main/java/com/github/manasmods/manascore/tab/InventoryTabHandler.java deleted file mode 100644 index 1ec61101..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/InventoryTabHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.ManasCore; -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import com.github.manasmods.manascore.client.gui.widget.InventoryTabSwitcherWidget; -import com.github.manasmods.manascore.api.tab.annotation.ScreenForTab; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.client.gui.screens.inventory.InventoryScreen; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ScreenEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.jetbrains.annotations.ApiStatus.Internal; - -import java.util.Map; - -@Internal -@Mod.EventBusSubscriber(modid = ManasCore.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) -public class InventoryTabHandler { - - @SubscribeEvent - public static void onOpenTabMenu(final ScreenEvent.Init e) { - if (!isValidTabScreen(e.getScreen())) return; - if (!(e.getScreen() instanceof AbstractContainerScreen containerScreen)) return; - - final Map tabRegistryEntries = InventoryTabRegistry.getEntries(); - InventoryTabSwitcherWidget tabSwitcherWidget = new InventoryTabSwitcherWidget(containerScreen, (int) Math.round(Math.ceil(tabRegistryEntries.size() / 12F))); - - tabRegistryEntries.forEach(tabSwitcherWidget::addUpdateListener); - tabSwitcherWidget.updateTabs(); - e.addListener(tabSwitcherWidget); - } - - private static boolean isValidTabScreen(Screen screen) { - if (screen instanceof InventoryScreen) return true; - return screen.getClass().isAnnotationPresent(ScreenForTab.class); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/InventoryTabRegistry.java b/src/main/java/com/github/manasmods/manascore/tab/InventoryTabRegistry.java deleted file mode 100644 index b31264db..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/InventoryTabRegistry.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import com.github.manasmods.manascore.api.tab.annotation.ScreenForTab; -import lombok.Getter; -import net.minecraft.client.gui.screens.Screen; -import org.jetbrains.annotations.ApiStatus.Internal; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Map; -import java.util.Optional; -import java.util.TreeMap; - -@Internal -public class InventoryTabRegistry { - @Getter - private static int nextEntryId = 1; - private static final TreeMap registeredTabs = new TreeMap<>(); - - public static void register(AbstractInventoryTab tab) { - registeredTabs.put(nextEntryId++, tab); - } - - public static Collection getValues() { - return registeredTabs.values(); - } - - public static Map getEntries() { - return Map.copyOf(registeredTabs); - } - - @Nullable - public static AbstractInventoryTab findByScreen(Screen screen) { - if (!screen.getClass().isAnnotationPresent(ScreenForTab.class)) return null; - ScreenForTab annotation = screen.getClass().getAnnotation(ScreenForTab.class); - Optional result = getValues().stream() - .filter(abstractInventoryTab -> annotation.value().isInstance(abstractInventoryTab)) - .findFirst(); - - return result.orElse(null); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/ManasCoreInventoryTabs.java b/src/main/java/com/github/manasmods/manascore/tab/ManasCoreInventoryTabs.java deleted file mode 100644 index 4f8d5db4..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/ManasCoreInventoryTabs.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.ManasCore; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = ManasCore.MOD_ID, value = Dist.CLIENT) -public class ManasCoreInventoryTabs { - @SubscribeEvent - public static void onClientInit(final FMLClientSetupEvent e) { - InventoryTabRegistry.register(new VanillaInventoryTab()); - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/TabPosition.java b/src/main/java/com/github/manasmods/manascore/tab/TabPosition.java deleted file mode 100644 index 4c2b4105..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/TabPosition.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.ManasCore; -import com.mojang.blaze3d.systems.RenderSystem; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus.Internal; - -@Internal -@AllArgsConstructor -public enum TabPosition { - LEFT_TOP(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/top-left.png"), false), - TOP(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/top.png"), false), - RIGHT_TOP(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/top-right.png"), false), - LEFT_BOT(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/bot-left.png"), true), - BOT(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/bot.png"), true), - RIGHT_BOT(new ResourceLocation(ManasCore.MOD_ID, "textures/gui/tabs/bot-right.png"), true); - - private final ResourceLocation tabLocation; - @Getter - private final boolean bottom; - - public void bindTexture() { - RenderSystem.setShaderTexture(0, this.tabLocation); - } - - public boolean isTop() { - return !this.bottom; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/VanillaInventoryTab.java b/src/main/java/com/github/manasmods/manascore/tab/VanillaInventoryTab.java deleted file mode 100644 index 757d1c14..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/VanillaInventoryTab.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022. ManasMods - */ - -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.ManasCore; -import com.github.manasmods.manascore.api.tab.AbstractInventoryTab; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.InventoryScreen; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.ApiStatus.Internal; - -import java.util.function.Predicate; - -@Internal -public class VanillaInventoryTab extends AbstractInventoryTab { - private final ItemStack iconStack = new ItemStack(Blocks.GRASS_BLOCK); - - public VanillaInventoryTab() { - super(Tooltip.create(Component.translatable("key.categories.inventory"))); - } - - @Override - protected void renderIcon(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) { - minecraft.getItemRenderer().renderAndDecorateFakeItem(this.iconStack, this.getX() + 6, this.getY() + 8); - } - - @Override - public void sendOpenContainerPacket() { - if (minecraft.player == null) { - ManasCore.getLogger().fatal("Local Player is null!?"); - return; - } - - minecraft.setScreen(new InventoryScreen(minecraft.player)); - } - - @Override - public Predicate isCurrentScreen() { - return screen -> screen instanceof InventoryScreen; - } -} diff --git a/src/main/java/com/github/manasmods/manascore/tab/package-info.java b/src/main/java/com/github/manasmods/manascore/tab/package-info.java deleted file mode 100644 index 7395d651..00000000 --- a/src/main/java/com/github/manasmods/manascore/tab/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package com.github.manasmods.manascore.tab; - -import com.github.manasmods.manascore.api.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 0cb59d0d..00000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,32 +0,0 @@ -modLoader = "javafml" #mandatory -loaderVersion = "${forgeLoaderVersion}" -license = "GPL-3" -issueTrackerURL = "https://github.com/ManasMods/ManasCore/issues" #optional -[[mods]] #mandatory -modId = "${modId}" #mandatory -version = "${modVersion}" -displayName = "ManasCore" #mandatory -updateJSONURL="https://api.modrinth.com/updates/wRRSWpd1/forge_updates.json" #optional -displayURL="https://github.com/ManasMods/ManasCore/wiki" #optional -logoFile="logo.jpg" #optional -#credits="Thanks for this example mod goes to Java" #optional -authors = "ManasMods" #optional -description = ''' -Utility and Core Library for Manas Mods -''' -#@formatter:off -[[dependencies.manascore]] #optional - modId="forge" #mandatory - mandatory=true #mandatory - versionRange="${forgeLoaderVersion}" #mandatory - ordering="NONE" - side="BOTH" -# Here's another dependency -[[dependencies.manascore]] - modId="minecraft" - mandatory=true - # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="${minecraftVersionCheck}" - ordering="NONE" - side="BOTH" -##@formatter:on \ No newline at end of file diff --git a/src/main/resources/assets/manascore/models/block/grass_like_inner_stairs.json b/src/main/resources/assets/manascore/models/block/grass_like_inner_stairs.json deleted file mode 100644 index 364eff63..00000000 --- a/src/main/resources/assets/manascore/models/block/grass_like_inner_stairs.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, - "north": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up" }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 8, 8 ], - "to": [ 8, 16, 16 ], - "faces": { - "up": { "uv": [ 0, 8, 8, 16 ], "texture": "#top", "cullface": "up" }, - "north": { "uv": [ 8, 0, 16, 8 ], "texture": "#side" }, - "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "west" } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/grass_like_outer_stairs.json b/src/main/resources/assets/manascore/models/block/grass_like_outer_stairs.json deleted file mode 100644 index 94fd6f71..00000000 --- a/src/main/resources/assets/manascore/models/block/grass_like_outer_stairs.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 8 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 8 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 8 ], "texture": "#top" }, - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 0, 8 ], - "to": [ 8, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 8, 8 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 8, 8 ], "texture": "#top" }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 8 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 8, 16, 16 ], "texture": "#top", "cullface": "up" }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#side" }, - "east": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 0, 8 ], - "to": [ 16, 8, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#bottom" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#bottom", "cullface": "south" }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#bottom" }, - "east": { "uv": [ 0, 0, 8, 8 ], "texture": "#bottom", "cullface": "east" }, - "down": { "uv": [ 0, 0, 8, 8 ], "texture": "#bottom", "cullface": "down" } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/grass_like_slab.json b/src/main/resources/assets/manascore/models/block/grass_like_slab.json deleted file mode 100644 index 64eae4eb..00000000 --- a/src/main/resources/assets/manascore/models/block/grass_like_slab.json +++ /dev/null @@ -1,18 +0,0 @@ -{ "parent": "block/block", - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top"}, - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/grass_like_slab_top.json b/src/main/resources/assets/manascore/models/block/grass_like_slab_top.json deleted file mode 100644 index 9104b09f..00000000 --- a/src/main/resources/assets/manascore/models/block/grass_like_slab_top.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "up"}, - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/grass_like_stairs.json b/src/main/resources/assets/manascore/models/block/grass_like_stairs.json deleted file mode 100644 index 6a60cb61..00000000 --- a/src/main/resources/assets/manascore/models/block/grass_like_stairs.json +++ /dev/null @@ -1,55 +0,0 @@ -{ "parent": "block/block", - "display": { - "gui": { - "rotation": [ 30, 135, 0 ], - "translation": [ 0, 0, 0], - "scale":[ 0.625, 0.625, 0.625 ] - }, - "head": { - "rotation": [ 0, -90, 0 ], - "translation": [ 0, 0, 0 ], - "scale": [ 1, 1, 1 ] - }, - "thirdperson_lefthand": { - "rotation": [ 75, -135, 0 ], - "translation": [ 0, 2.5, 0], - "scale": [ 0.375, 0.375, 0.375 ] - } - }, - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 8, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up" }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "north": { "uv": [ 8, 8, 16, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 8, 16, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up"}, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/overlay_inner_stairs.json b/src/main/resources/assets/manascore/models/block/overlay_inner_stairs.json deleted file mode 100644 index 88423dce..00000000 --- a/src/main/resources/assets/manascore/models/block/overlay_inner_stairs.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 }, - "north": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 8, 8 ], - "to": [ 8, 16, 16 ], - "faces": { - "up": { "uv": [ 0, 8, 8, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, - "north": { "uv": [ 8, 0, 16, 8 ], "texture": "#side" }, - "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "west" } - } - }, - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "north": { "uv": [ 0, 8, 16, 16 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 0, 8, 16, 16 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - }, - { "from": [ 0, 8, 8 ], - "to": [ 8, 16, 16 ], - "faces": { - "north": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0 }, - "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/overlay_outer_stairs.json b/src/main/resources/assets/manascore/models/block/overlay_outer_stairs.json deleted file mode 100644 index cb54a711..00000000 --- a/src/main/resources/assets/manascore/models/block/overlay_outer_stairs.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 }, - "north": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 8 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 8, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#side" }, - "east": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - }, - { "from": [ 8, 8, 8 ], - "to": [ 16, 16, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "tintindex": 0 }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/overlay_slab.json b/src/main/resources/assets/manascore/models/block/overlay_slab.json deleted file mode 100644 index 1d4fdabe..00000000 --- a/src/main/resources/assets/manascore/models/block/overlay_slab.json +++ /dev/null @@ -1,27 +0,0 @@ -{ "parent": "block/block", - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 }, - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/overlay_slab_top.json b/src/main/resources/assets/manascore/models/block/overlay_slab_top.json deleted file mode 100644 index b2935e96..00000000 --- a/src/main/resources/assets/manascore/models/block/overlay_slab_top.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/models/block/overlay_stairs.json b/src/main/resources/assets/manascore/models/block/overlay_stairs.json deleted file mode 100644 index a6658499..00000000 --- a/src/main/resources/assets/manascore/models/block/overlay_stairs.json +++ /dev/null @@ -1,72 +0,0 @@ -{ "parent": "block/block", - "display": { - "gui": { - "rotation": [ 30, 135, 0 ], - "translation": [ 0, 0, 0], - "scale":[ 0.625, 0.625, 0.625 ] - }, - "head": { - "rotation": [ 0, -90, 0 ], - "translation": [ 0, 0, 0 ], - "scale": [ 1, 1, 1 ] - }, - "thirdperson_lefthand": { - "rotation": [ 75, -135, 0 ], - "translation": [ 0, 2.5, 0], - "scale": [ 0.375, 0.375, 0.375 ] - } - }, - "textures": { - "particle": "#side" - }, - "elements": [ - { "from": [ 0, 0, 0 ], - "to": [ 8, 8, 16 ], - "faces": { - "down": { "uv": [ 0, 0, 8, 16 ], "texture": "#top", "cullface": "down", "tintindex": 0 }, - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "tintindex": 0 }, - "north": { "uv": [ 0, 8, 8, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 0, 8, 8, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 0, 0 ], - "to": [ 16, 8, 16 ], - "faces": { - "down": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "down", "tintindex": 0 }, - "north": { "uv": [ 8, 8, 16, 16 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 8, 16, 16 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "up": { "uv": [ 8, 0, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#side", "cullface": "north" }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#side", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#side", "cullface": "east" } - } - }, - { "from": [ 0, 0, 0 ], - "to": [ 8, 8, 16 ], - "faces": { - "north": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 } - } - }, - { "from": [ 8, 8, 0 ], - "to": [ 16, 16, 16 ], - "faces": { - "north": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "cullface": "north", "tintindex": 0 }, - "south": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "cullface": "south", "tintindex": 0 }, - "west": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "west", "tintindex": 0 }, - "east": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "cullface": "east", "tintindex": 0 } - } - } - ] -} diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/bot-left.png b/src/main/resources/assets/manascore/textures/gui/tabs/bot-left.png deleted file mode 100644 index 09c43927..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/bot-left.png and /dev/null differ diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/bot-right.png b/src/main/resources/assets/manascore/textures/gui/tabs/bot-right.png deleted file mode 100644 index 19396697..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/bot-right.png and /dev/null differ diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/bot.png b/src/main/resources/assets/manascore/textures/gui/tabs/bot.png deleted file mode 100644 index f96dd77c..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/bot.png and /dev/null differ diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/top-left.png b/src/main/resources/assets/manascore/textures/gui/tabs/top-left.png deleted file mode 100644 index 2970e398..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/top-left.png and /dev/null differ diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/top-right.png b/src/main/resources/assets/manascore/textures/gui/tabs/top-right.png deleted file mode 100644 index 3b78cbdd..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/top-right.png and /dev/null differ diff --git a/src/main/resources/assets/manascore/textures/gui/tabs/top.png b/src/main/resources/assets/manascore/textures/gui/tabs/top.png deleted file mode 100644 index 45b139f6..00000000 Binary files a/src/main/resources/assets/manascore/textures/gui/tabs/top.png and /dev/null differ diff --git a/src/main/resources/logo.jpg b/src/main/resources/logo.jpg deleted file mode 100644 index 46fab4b1..00000000 Binary files a/src/main/resources/logo.jpg and /dev/null differ diff --git a/src/main/resources/manascore.mixins.json b/src/main/resources/manascore.mixins.json deleted file mode 100644 index 2191ec24..00000000 --- a/src/main/resources/manascore.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "com.github.manasmods.manascore.core", - "compatibilityLevel": "JAVA_17", - "refmap": "manascore.refmap.json", - "mixins": [ - "BlockLootSubProviderAccessor", - "ShapedRecipeBuilderAccessor", - "VanillaBlockLootAccessor" - ], - "client": [ - "AbstractContainerScreenAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta deleted file mode 100644 index ffebef6f..00000000 --- a/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "ManasCore resources", - "pack_format": 8 - } -}