Initial commit

This commit is contained in:
Buuz135 2021-12-18 01:36:34 +01:00
commit 65395632b9
61 changed files with 1735 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
*.ipr
*.iws
*.iml
.idea
# gradle
logs
build
.gradle
# other
eclipse
run
classes

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2021 Buuz135, Rid
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1 +1,2 @@
# FunctionalStorage
FunctionalStorage FunctionalStorage

99
build.gradle Normal file
View File

@ -0,0 +1,99 @@
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
group = 'com.buuz135'
version = '1.0.0'
java {
archivesBaseName = 'functionalstorage'
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
minecraft {
mappings channel: 'official', version: '1.18.1'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
functionalstorage {
source sourceSets.main
}
}
}
server {
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
functionalstorage {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'functionalstorage', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
functionalstorage {
source sourceSets.main
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven {
name 'jared maven'
url "https://maven.blamejared.com/"
}
}
dependencies {
minecraft 'net.minecraftforge:forge:1.18.1-39.0.5'
implementation fg.deobf (project.dependencies.create('com.hrznstudio:titanium:1.18-3.4.0-21'))
}
// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
"Specification-Title" : "functionalstorage",
"Specification-Vendor" : "Buuz135, Rid",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "Buuz135, Rid",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')

2
gradle.properties Normal file
View File

@ -0,0 +1,2 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
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

234
gradlew vendored Normal file
View File

@ -0,0 +1,234 @@
#!/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" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@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

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'functionalstorage'

View File

@ -0,0 +1,21 @@
ad618fbf42f1c54275c29beaa25710bca73acef2 assets/functionalstorage/blockstates/acacia_wood_x_1.json
4521d6ecf273477d76f604e778834d2943219072 assets/functionalstorage/blockstates/acacia_wood_x_2.json
182f44d09ec408599466201e69efe9bc88b479c0 assets/functionalstorage/blockstates/acacia_wood_x_4.json
3b02d94db9f2f0b4d9b7b4a412427929a6f87d2b assets/functionalstorage/blockstates/birch_wood_x_1.json
7bd0dc17af1d849100a423ca36eacb767bb2b1ea assets/functionalstorage/blockstates/birch_wood_x_2.json
7e20830acae23717dd782ebf628e5eef778de0c1 assets/functionalstorage/blockstates/birch_wood_x_4.json
e0fee0fdb3a3e76bd6ca5a8f92f7c6c5e54b5e23 assets/functionalstorage/blockstates/crimson_hyphae_x_1.json
17eec305ac9c19c66a32af11de2e1a528fa00894 assets/functionalstorage/blockstates/crimson_hyphae_x_2.json
ffcd4cbf2a5406b7e4f96e87ad643b1feb18caf3 assets/functionalstorage/blockstates/crimson_hyphae_x_4.json
a75ff2ba030156b42ed5e545fbf8e06f9854bf2c assets/functionalstorage/blockstates/jungle_wood_x_1.json
19ae7afc5de0593b427309159c299e8d2ddfc4cd assets/functionalstorage/blockstates/jungle_wood_x_2.json
228dd78c840b995c601704c32eaf17fe007d0346 assets/functionalstorage/blockstates/jungle_wood_x_4.json
677884e1ddd4f366b13040d4e0a61b8b80af66f1 assets/functionalstorage/blockstates/oak_wood_x_1.json
1890327c4df849f1edc8ff55dfa9a29b178a926c assets/functionalstorage/blockstates/oak_wood_x_2.json
20cf26a5c3131f3eefb0fc990775d8888cf5a040 assets/functionalstorage/blockstates/oak_wood_x_4.json
8c5ebf28cbfe4f8f67356de1c35323c5ffe2893a assets/functionalstorage/blockstates/spruce_wood_x_1.json
63f91dfa4ccc3c935eb5c509ef8d5b8dec08eaf7 assets/functionalstorage/blockstates/spruce_wood_x_2.json
67ebf02f1106575b2ad25b9cc42db06eed1a4ff6 assets/functionalstorage/blockstates/spruce_wood_x_4.json
3bb73e777f6977390b83eba51463e9584cd332ae assets/functionalstorage/blockstates/warped_hyphae_x_1.json
42ca0c251f479a2cf839738d1a65b03358c309b3 assets/functionalstorage/blockstates/warped_hyphae_x_2.json
3756536ab32dc69545328177f3e5c734061b7ab6 assets/functionalstorage/blockstates/warped_hyphae_x_4.json

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/acacia_wood_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/acacia_wood_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/acacia_wood_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/acacia_wood_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/acacia_wood_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/acacia_wood_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/acacia_wood_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/acacia_wood_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/acacia_wood_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/acacia_wood_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/acacia_wood_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/acacia_wood_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/birch_wood_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/birch_wood_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/birch_wood_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/birch_wood_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/birch_wood_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/birch_wood_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/birch_wood_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/birch_wood_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/birch_wood_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/birch_wood_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/birch_wood_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/birch_wood_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/crimson_hyphae_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/crimson_hyphae_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/crimson_hyphae_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/crimson_hyphae_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/crimson_hyphae_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/crimson_hyphae_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/crimson_hyphae_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/crimson_hyphae_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/crimson_hyphae_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/crimson_hyphae_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/crimson_hyphae_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/crimson_hyphae_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/jungle_wood_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/jungle_wood_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/jungle_wood_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/jungle_wood_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/jungle_wood_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/jungle_wood_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/jungle_wood_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/jungle_wood_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/jungle_wood_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/jungle_wood_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/jungle_wood_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/jungle_wood_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/oak_wood_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/oak_wood_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/oak_wood_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/oak_wood_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/oak_wood_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/oak_wood_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/oak_wood_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/oak_wood_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/oak_wood_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/oak_wood_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/oak_wood_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/oak_wood_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/spruce_wood_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/spruce_wood_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/spruce_wood_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/spruce_wood_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/spruce_wood_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/spruce_wood_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/spruce_wood_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/spruce_wood_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/spruce_wood_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/spruce_wood_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/spruce_wood_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/spruce_wood_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/warped_hyphae_x_1"
},
"subfacing=south": {
"model": "functionalstorage:block/warped_hyphae_x_1",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/warped_hyphae_x_1",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/warped_hyphae_x_1",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/warped_hyphae_x_2"
},
"subfacing=south": {
"model": "functionalstorage:block/warped_hyphae_x_2",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/warped_hyphae_x_2",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/warped_hyphae_x_2",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"subfacing=north": {
"model": "functionalstorage:block/warped_hyphae_x_4"
},
"subfacing=south": {
"model": "functionalstorage:block/warped_hyphae_x_4",
"y": 180
},
"subfacing=west": {
"model": "functionalstorage:block/warped_hyphae_x_4",
"y": 270
},
"subfacing=east": {
"model": "functionalstorage:block/warped_hyphae_x_4",
"y": 90
}
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/acacia_wood_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/acacia_wood_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/acacia_wood_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/birch_wood_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/birch_wood_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/birch_wood_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/crimson_hyphae_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/crimson_hyphae_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/crimson_hyphae_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/jungle_wood_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/jungle_wood_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/jungle_wood_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/oak_wood_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/oak_wood_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/oak_wood_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/spruce_wood_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/spruce_wood_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/spruce_wood_x_4"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/warped_hyphae_x_1"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/warped_hyphae_x_2"
}

View File

@ -0,0 +1,3 @@
{
"parent": "functionalstorage:block/warped_hyphae_x_4"
}

View File

@ -0,0 +1,119 @@
package com.buuz135.functionalstorage;
import com.buuz135.functionalstorage.block.DrawerBlock;
import com.buuz135.functionalstorage.client.DrawerRenderer;
import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider;
import com.hrznstudio.titanium.block.BasicTileBlock;
import com.hrznstudio.titanium.datagenerator.model.BlockItemModelGeneratorProvider;
import com.hrznstudio.titanium.event.handler.EventManager;
import com.hrznstudio.titanium.module.ModuleController;
import com.hrznstudio.titanium.tab.AdvancedTitaniumTab;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.common.util.NonNullLazy;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.stream.Collectors;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("functionalstorage")
public class FunctionalStorage extends ModuleController {
public static String MOD_ID = "functionalstorage";
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
public static List<String> WOOD_TYPES = new ArrayList<>();
public static HashMap<DrawerType, List<RegistryObject<Block>>> DRAWER_TYPES = new HashMap<>();
public static AdvancedTitaniumTab TAB = new AdvancedTitaniumTab("functionalstorage", true);
public FunctionalStorage() {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::onClient);
}
public void addWood(Block block){
WOOD_TYPES.add(block.getRegistryName().getPath());
}
@Override
protected void initModules() {
addWood(Blocks.OAK_WOOD);
addWood(Blocks.SPRUCE_WOOD);
addWood(Blocks.BIRCH_WOOD);
addWood(Blocks.JUNGLE_WOOD);
addWood(Blocks.ACACIA_WOOD);
addWood(Blocks.CRIMSON_HYPHAE);
addWood(Blocks.WARPED_HYPHAE);
for (DrawerType value : DrawerType.values()) {
for (String woodType : WOOD_TYPES) {
String name = woodType + "_" + value.name().toLowerCase(Locale.ROOT);
DRAWER_TYPES.computeIfAbsent(value, drawerType -> new ArrayList<>()).add(getRegistries().register(Block.class, name, () -> new DrawerBlock(name, value)));
}
DRAWER_TYPES.get(value).forEach(blockRegistryObject -> TAB.addIconStacks(() -> new ItemStack(blockRegistryObject.get())));
}
}
public enum DrawerType{
X_1(1, 32 * 64), X_2(2, 16 * 64), X_4(4, 8 * 64);
private final int slots;
private final int slotAmount;
private DrawerType(int slots, int slotAmount){
this.slots = slots;
this.slotAmount = slotAmount;
}
public int getSlots() {
return slots;
}
public int getSlotAmount() {
return slotAmount;
}
}
@OnlyIn(Dist.CLIENT)
public void onClient(){
EventManager.mod(EntityRenderersEvent.RegisterRenderers.class).process(registerRenderers -> {
for (DrawerType value : DrawerType.values()) {
DRAWER_TYPES.get(value).forEach(blockRegistryObject -> {
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock)blockRegistryObject.get()).getTileEntityType(), p_173571_ -> new DrawerRenderer());
});
}
}).subscribe();
}
@Override
public void addDataProvider(GatherDataEvent event) {
NonNullLazy<List<Block>> blocksToProcess = NonNullLazy.of(() ->
ForgeRegistries.BLOCKS.getValues()
.stream()
.filter(basicBlock -> Optional.ofNullable(basicBlock.getRegistryName())
.map(ResourceLocation::getNamespace)
.filter(MOD_ID::equalsIgnoreCase)
.isPresent())
.collect(Collectors.toList())
);
event.getGenerator().addProvider(new BlockItemModelGeneratorProvider(event.getGenerator(), MOD_ID, blocksToProcess));
event.getGenerator().addProvider(new FunctionalStorageBlockstateProvider(event.getGenerator(), event.getExistingFileHelper(), blocksToProcess));
}
}

View File

@ -0,0 +1,133 @@
package com.buuz135.functionalstorage.block;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.hrznstudio.titanium.block.RotatableBlock;
import com.hrznstudio.titanium.module.DeferredRegistryHelper;
import com.hrznstudio.titanium.util.RayTraceUtils;
import com.hrznstudio.titanium.util.TileUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Predicate;
public class DrawerBlock extends RotatableBlock<DrawerTile> {
public static HashMap<FunctionalStorage.DrawerType, Multimap<Direction, VoxelShape>> CACHED_SHAPES = new HashMap<>();
static {
CACHED_SHAPES.computeIfAbsent(FunctionalStorage.DrawerType.X_1, type1 -> MultimapBuilder.hashKeys().arrayListValues().build())
.put(Direction.NORTH, Shapes.box(1/16D, 1/16D, 0, 15/16D, 15/16D, 1/16D));
CACHED_SHAPES.computeIfAbsent(FunctionalStorage.DrawerType.X_1, type1 -> MultimapBuilder.hashKeys().arrayListValues().build())
.put(Direction.SOUTH, Shapes.box(1/16D, 1/16D, 1/16D, 15/16D, 15/16D, 1));
CACHED_SHAPES.computeIfAbsent(FunctionalStorage.DrawerType.X_1, type1 -> MultimapBuilder.hashKeys().arrayListValues().build())
.put(Direction.WEST, Shapes.box(0, 1/16D, 1/16D, 1/16D, 15/16D, 15/16D));
CACHED_SHAPES.computeIfAbsent(FunctionalStorage.DrawerType.X_1, type1 -> MultimapBuilder.hashKeys().arrayListValues().build())
.put(Direction.EAST, Shapes.box(15/16D, 1/16D, 1/16D, 1, 15/16D, 15/16D));
}
private final FunctionalStorage.DrawerType type;
public DrawerBlock(String name, FunctionalStorage.DrawerType type) {
super(name, Properties.copy(Blocks.OAK_PLANKS), DrawerTile.class);
this.type = type;
setItemGroup(FunctionalStorage.TAB);
registerDefaultState(defaultBlockState().setValue(RotatableBlock.FACING_HORIZONTAL, Direction.NORTH));
}
@Override
public void addAlternatives(DeferredRegistryHelper registry) {
super.addAlternatives(registry);
}
@NotNull
@Override
public RotationType getRotationType() {
return RotationType.FOUR_WAY;
}
@Override
public BlockEntityType.BlockEntitySupplier<DrawerTile> getTileEntityFactory() {
return (blockPos, state) -> new DrawerTile(this, blockPos, state, type);
}
@Override
public List<VoxelShape> getBoundingBoxes(BlockState state, BlockGetter source, BlockPos pos) {
return getShapes(state, source, pos, this.type);
}
private static List<VoxelShape> getShapes(BlockState state, BlockGetter source, BlockPos pos, FunctionalStorage.DrawerType type){
List<VoxelShape> boxes = new ArrayList<>();
CACHED_SHAPES.get(type).get(state.getValue(RotatableBlock.FACING_HORIZONTAL)).forEach(boxes::add);
VoxelShape total = Shapes.block();
boxes.add(total);
return boxes;
}
@Nonnull
@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
return Shapes.box(0, 0, 0, 1,1,1);
}
@Override
public boolean hasCustomBoxes(BlockState state, BlockGetter source, BlockPos pos) {
return true;
}
@Override
public boolean hasIndividualRenderVoxelShape() {
return true;
}
@Override
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
return TileUtil.getTileEntity(worldIn, pos, DrawerTile.class).map(drawerTile -> drawerTile.onSlotActivated(player, hand, ray.getDirection(), ray.getLocation().x, ray.getLocation().y, ray.getLocation().z, getHit(state, worldIn, pos, player))).orElse(InteractionResult.PASS);
}
@Override
public void attack(BlockState state, Level worldIn, BlockPos pos, Player player) {
TileUtil.getTileEntity(worldIn, pos, DrawerTile.class).ifPresent(drawerTile -> drawerTile.onClicked(player, getHit(state, worldIn, pos, player)));
}
public int getHit(BlockState state, Level worldIn, BlockPos pos, Player player) {
HitResult result = RayTraceUtils.rayTraceSimple(worldIn, player, 32, 0);
if (result instanceof BlockHitResult) {
VoxelShape hit = RayTraceUtils.rayTraceVoxelShape((BlockHitResult) result, worldIn, player, 32, 0);
if (hit != null) {
if (hit.equals(Shapes.block())) return -1;
List<VoxelShape> shapes = new ArrayList<>();
shapes.addAll(CACHED_SHAPES.get(type).get(state.getValue(RotatableBlock.FACING_HORIZONTAL)));
for (int i = 0; i < shapes.size(); i++) {
System.out.println(shapes.get(i));
if (Shapes.joinIsNotEmpty(shapes.get(i), hit, BooleanOp.AND)) {
return i;
}
}
}
}
return -1;
}
}

View File

@ -0,0 +1,112 @@
package com.buuz135.functionalstorage.block.tile;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
import com.hrznstudio.titanium.annotation.Save;
import com.hrznstudio.titanium.block.BasicTileBlock;
import com.hrznstudio.titanium.block.tile.ActiveTile;
import com.hrznstudio.titanium.block.tile.BasicTile;
import com.hrznstudio.titanium.nbthandler.NBTManager;
import com.hrznstudio.titanium.util.RayTraceUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.UUID;
public class DrawerTile extends ActiveTile<DrawerTile> {
private static HashMap<UUID, Long> INTERACTION_LOGGER = new HashMap<>();
@Save
public BigInventoryHandler handler;
private final LazyOptional<IItemHandler> lazyStorage;
private FunctionalStorage.DrawerType type;
public DrawerTile(BasicTileBlock<DrawerTile> base, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) {
super(base, pos, state);
this.type = type;
this.handler = new BigInventoryHandler(type) {
@Override
public void onChange() {
DrawerTile.this.markForUpdate();
}
};
lazyStorage = LazyOptional.of(() -> this.handler);
}
public InteractionResult onSlotActivated(Player playerIn, InteractionHand hand, Direction facing, double hitX, double hitY, double hitZ, int slot) {
if (super.onActivated(playerIn, hand, facing, hitX, hitY, hitZ) == InteractionResult.SUCCESS) {
return InteractionResult.SUCCESS;
}
if (slot == -1){
openGui(playerIn);
} else if (isServer()){
ItemStack stack = playerIn.getItemInHand(hand);
if (!stack.isEmpty() && handler.isItemValid(slot, stack)) {
playerIn.setItemInHand(hand, handler.insertItem(slot, stack, false));
} else if (System.currentTimeMillis() - INTERACTION_LOGGER.getOrDefault(playerIn.getUUID(), System.currentTimeMillis()) < 300) {
for (ItemStack itemStack : playerIn.getInventory().items) {
if (!itemStack.isEmpty() && handler.insertItem(slot, itemStack, true).isEmpty()) {
handler.insertItem(slot, itemStack.copy(), false);
itemStack.setCount(0);
}
}
}
INTERACTION_LOGGER.put(playerIn.getUUID(), System.currentTimeMillis());
}
return InteractionResult.SUCCESS;
}
public void onClicked(Player playerIn, int slot) {
if (isServer()){
HitResult rayTraceResult = RayTraceUtils.rayTraceSimple(this.level, playerIn, 16, 0);
if (rayTraceResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockResult = (BlockHitResult) rayTraceResult;
Direction facing = blockResult.getDirection();
if (facing.equals(this.getFacingDirection())){
ItemHandlerHelper.giveItemToPlayer(playerIn, handler.extractItem(slot, playerIn.isShiftKeyDown() ? 64 : 1, false));
}
}
}
}
@Nonnull
@Override
public <U> LazyOptional<U> getCapability(@Nonnull Capability<U> cap, @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return lazyStorage.cast();
}
return super.getCapability(cap, side);
}
@NotNull
@Override
public DrawerTile getSelf() {
return this;
}
public BigInventoryHandler getHandler() {
return handler;
}
public FunctionalStorage.DrawerType getDrawerType() {
return type;
}
}

View File

@ -0,0 +1,135 @@
package com.buuz135.functionalstorage.client;
import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> {
private static final Matrix3f FAKE_NORMALS;
static {
Vector3f NORMAL = new Vector3f(1, 1, 1);
NORMAL.normalize();
FAKE_NORMALS = new Matrix3f(new Quaternion(NORMAL, 0, true));
}
@Override
public void render(DrawerTile tile, float partialTicks, PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
matrixStack.pushPose();
Direction facing = tile.getFacingDirection();
matrixStack.mulPose(Vector3f.YP.rotationDegrees(-180));
matrixStack.last().normal().load(FAKE_NORMALS);
if (facing == Direction.NORTH) {
//matrixStack.translate(0, 0, 1.016 / 16D);
matrixStack.translate(-1, 0, 0);
}
if (facing == Direction.EAST) {
matrixStack.translate(-1, 0, -1);
matrixStack.mulPose(Vector3f.YP.rotationDegrees(-90));
}
if (facing == Direction.SOUTH) {
matrixStack.translate(0, 0,-1);
matrixStack.mulPose(Vector3f.YP.rotationDegrees(-180));
}
if (facing == Direction.WEST) {
matrixStack.mulPose(Vector3f.YP.rotationDegrees(90));
}
//matrixStack.last().normal().add(FAKE_NORMALS);
combinedLightIn = LevelRenderer.getLightColor(tile.getLevel(), tile.getBlockPos().relative(facing));
render1Slot(matrixStack, bufferIn, combinedLightIn, combinedOverlayIn, tile);
}
private void render1Slot(PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, DrawerTile tile){
//System.out.println(tile.getHandler().getStackInSlot(0));
if (!tile.getHandler().getStackInSlot(0).isEmpty()){
matrixStack.translate(0.5, 0.5, 0.0005f);
ItemStack stack = tile.getHandler().getStackInSlot(0);
renderStack(matrixStack, bufferIn, combinedLightIn, combinedOverlayIn, stack, stack.getCount());
matrixStack.popPose();
renderText(matrixStack, bufferIn, combinedOverlayIn, new TextComponent(ChatFormatting.WHITE + "" + stack.getCount()), tile.getFacingDirection(), 0.007f);
}else {
matrixStack.popPose();
}
}
private void renderStack(PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, ItemStack stack, int amount){
if (stack.getItem() instanceof BlockItem){
matrixStack.scale(0.5f, 0.5f, 0.0001f);
} else {
matrixStack.scale(0.4f, 0.4f, 0.0001f);
}
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GUI, combinedLightIn, combinedOverlayIn, matrixStack, bufferIn, 0);
}
/* Thanks Mekanism */
private void renderText(PoseStack matrix, MultiBufferSource renderer, int overlayLight, Component text, Direction side, float maxScale) {
matrix.pushPose();
matrix.translate(0, -0.3725, 0);
switch (side) {
case SOUTH:
matrix.translate(0, 1, 0.0001);
matrix.mulPose(Vector3f.XP.rotationDegrees(90));
break;
case NORTH:
matrix.translate(1, 1, 0.9999);
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
matrix.mulPose(Vector3f.XP.rotationDegrees(90));
break;
case EAST:
matrix.translate(0.0001, 1, 1);
matrix.mulPose(Vector3f.YP.rotationDegrees(90));
matrix.mulPose(Vector3f.XP.rotationDegrees(90));
break;
case WEST:
matrix.translate(0.9999, 1, 0);
matrix.mulPose(Vector3f.YP.rotationDegrees(-90));
matrix.mulPose(Vector3f.XP.rotationDegrees(90));
break;
}
float displayWidth = 1;
float displayHeight = 1;
matrix.translate(displayWidth / 2, 1, displayHeight / 2);
matrix.mulPose(Vector3f.XP.rotationDegrees(-90));
Font font = Minecraft.getInstance().font;
int requiredWidth = Math.max(font.width(text), 1);
int requiredHeight = font.lineHeight + 2;
float scaler = 0.4F;
float scaleX = displayWidth / requiredWidth;
float scale = scaleX * scaler;
if (maxScale > 0) {
scale = Math.min(scale, maxScale);
}
matrix.scale(scale, -scale, scale);
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
int offsetX = (realWidth - requiredWidth) / 2;
int offsetY = (realHeight - requiredHeight) / 2;
font.drawInBatch(text, offsetX - realWidth / 2, 3 + offsetY - realHeight / 2, overlayLight,
false, matrix.last().pose(), renderer, false, 0, 0xF000F0);
matrix.popPose();
}
}

View File

@ -0,0 +1,51 @@
package com.buuz135.functionalstorage.data;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.hrznstudio.titanium.block.RotatableBlock;
import net.minecraft.core.Direction;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.common.util.NonNullLazy;
import java.util.List;
public class FunctionalStorageBlockstateProvider extends BlockStateProvider {
private ExistingFileHelper helper;
private final NonNullLazy<List<Block>> blocks;
public FunctionalStorageBlockstateProvider(DataGenerator gen, ExistingFileHelper exFileHelper, NonNullLazy<List<Block>> blocks) {
super(gen, FunctionalStorage.MOD_ID, exFileHelper);
this.helper = exFileHelper;
this.blocks = blocks;
}
public static ResourceLocation getModel(Block block) {
return new ResourceLocation(block.getRegistryName().getNamespace(), "block/" + block.getRegistryName().getPath());
}
@Override
protected void registerStatesAndModels() {
blocks.get().stream().filter(blockBase -> blockBase instanceof RotatableBlock)
.map(blockBase -> (RotatableBlock) blockBase)
.forEach(rotatableBlock -> {
VariantBlockStateBuilder builder = getVariantBuilder(rotatableBlock);
if (rotatableBlock.getRotationType().getProperties().length > 0) {
for (DirectionProperty property : rotatableBlock.getRotationType().getProperties()) {
for (Direction allowedValue : property.getPossibleValues()) {
builder.partialState().with(property, allowedValue)
.addModels(new ConfiguredModel(new ModelFile.UncheckedModelFile(getModel(rotatableBlock)), allowedValue.get2DDataValue() == -1 ? allowedValue.getOpposite().getAxisDirection().getStep() * 90 : 0, (int) allowedValue.getOpposite().toYRot(), false));
}
}
} else {
builder.partialState().addModels(new ConfiguredModel(new ModelFile.UncheckedModelFile(getModel(rotatableBlock))));
}
});
}
}

View File

@ -0,0 +1,161 @@
package com.buuz135.functionalstorage.inventory;
import com.buuz135.functionalstorage.FunctionalStorage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public abstract class BigInventoryHandler implements IItemHandler, INBTSerializable<CompoundTag> {
public static String VOID = "Void";
public static String BIG_ITEMS = "BigItems";
public static String STACK = "Stack";
public static String AMOUNT = "Amount";
private final FunctionalStorage.DrawerType type;
private List<BigStack> storedStacks;
private boolean voidItems;
public BigInventoryHandler(FunctionalStorage.DrawerType type){
this.type = type;
this.storedStacks = new ArrayList<>();
for (int i = 0; i < type.getSlots(); i++) {
this.storedStacks.add(i, new BigStack(ItemStack.EMPTY, 0));
}
this.voidItems = false;
}
@Override
public int getSlots() {
return type.getSlots();
}
@Nonnull
@Override
public ItemStack getStackInSlot(int slot) {
BigStack bigStack = this.storedStacks.get(slot);
ItemStack copied = bigStack.getStack().copy();
copied.setCount(bigStack.getAmount());
return copied;
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (isItemValid(slot, stack)) {
BigStack bigStack = this.storedStacks.get(slot);
int inserted = Math.min(type.getSlotAmount() - bigStack.getAmount(), stack.getCount());
if (!simulate){
bigStack.setStack(stack);
bigStack.setAmount(Math.min(bigStack.getAmount() + inserted, type.getSlotAmount()));
onChange();
}
if (inserted == stack.getCount() || voidItems) return ItemStack.EMPTY;
return ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - inserted);
}
return stack;
}
@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (amount == 0) return ItemStack.EMPTY;
if (slot < type.getSlots()){
BigStack bigStack = this.storedStacks.get(slot);
if (bigStack.getStack().isEmpty()) return ItemStack.EMPTY;
if (bigStack.getAmount() <= amount) {
ItemStack out = bigStack.getStack().copy();
int newAmount = bigStack.getAmount();
if (!simulate) {
bigStack.setStack(ItemStack.EMPTY); //TODO Dont change if locked
bigStack.setAmount(0);
onChange();
}
out.setCount(newAmount);
return out;
} else {
if (!simulate) {
bigStack.setAmount(bigStack.getAmount() - amount);
onChange();
}
return ItemHandlerHelper.copyStackWithSize(bigStack.getStack(), amount);
}
}
return ItemStack.EMPTY;
}
@Override
public int getSlotLimit(int slot) {
return type.getSlotAmount();
}
@Override
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
if (slot < type.getSlots()){
BigStack bigStack = this.storedStacks.get(slot);
ItemStack fl = bigStack.getStack();
return fl.isEmpty() || (fl.sameItem(stack) && ItemStack.tagMatches(fl, stack));
}
return false;
}
@Override
public CompoundTag serializeNBT() {
CompoundTag compoundTag = new CompoundTag();
compoundTag.putBoolean(VOID, voidItems);
CompoundTag items = new CompoundTag();
for (int i = 0; i < this.storedStacks.size(); i++) {
CompoundTag bigStack = new CompoundTag();
bigStack.put(STACK, this.storedStacks.get(i).getStack().serializeNBT());
bigStack.putInt(AMOUNT, this.storedStacks.get(i).getAmount());
items.put(i + "", bigStack);
}
compoundTag.put(BIG_ITEMS, items);
return compoundTag;
}
@Override
public void deserializeNBT(CompoundTag nbt) {
this.voidItems = nbt.getBoolean(VOID);
for (String allKey : nbt.getCompound(BIG_ITEMS).getAllKeys()) {
System.out.println(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getCompound(STACK));
this.storedStacks.get(Integer.parseInt(allKey)).setStack(ItemStack.of(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getCompound(STACK)));
this.storedStacks.get(Integer.parseInt(allKey)).setAmount(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getInt(AMOUNT));
}
}
public abstract void onChange();
public class BigStack{
private ItemStack stack;
private int amount;
public BigStack(ItemStack stack, int amount) {
this.stack = stack;
this.amount = amount;
}
public ItemStack getStack() {
return stack;
}
public void setStack(ItemStack stack) {
this.stack = stack;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
}
}

View File

@ -0,0 +1,58 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader = "javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion = "[39,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license = "MIT"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="http://my.issue.tracker/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId = "functionalstorage" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version = "${file.jarVersion}" #mandatory
# A display name for the mod
displayName = "Functionalstorage" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
#updateJSONURL="http://myurl.me/" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="http://example.com/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="functionalstorage.png" #optional
# A text field displayed in the mod UI
#credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors = "Buuz135, Rid" #optional
# The description text for the mod (multi line!) (#mandatory)
description = '''
Functional Storage
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.functionalstorage]] #optional
# the modid of the dependency
modId = "forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory = true #mandatory
# The version range of the dependency
versionRange = "[39,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering = "NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side = "BOTH"
# Here's another dependency
[[dependencies.functionalstorage]]
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 = "[1.18.1,1.19)"
ordering = "NONE"
side = "BOTH"

View File

@ -0,0 +1,6 @@
{
"pack": {
"description": "functionalstorage resources",
"pack_format": 8
}
}