Everything was done

This commit is contained in:
Andrew 2023-03-26 16:20:21 +07:00
commit 89a89a6e21
108 changed files with 4570 additions and 0 deletions

118
.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

130
build.gradle Normal file
View file

@ -0,0 +1,130 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
repositories {
maven { url 'https://maven.blamejared.com' }
maven { url 'https://maven.theillusivec4.top' }
maven { url 'https://maven.hellfiredev.net' }
}
apply plugin: 'net.minecraftforge.gradle'
group = 'xyz.nuark.mods'
version = '1.16.5-1.1.0'
archivesBaseName = 'ElectroMana'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
mappings channel: 'snapshot', version: '20210309-1.16.5'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
electromana {
source sourceSets.main
}
}
}
server {
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
electromana {
source sourceSets.main
}
}
}
data {
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
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', 'electromana', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
electromana {
source sourceSets.main
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.1.16'
def curios_version = "1.16.5-4.0.5.1"
def patchouli_version = "1.16.4-51"
def botania_version = "1.16.5-416"
compileOnly "top.theillusivec4.curios:curios-forge:$curios_version:api"
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:$curios_version")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouli_version:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouli_version")
compileOnly fg.deobf("vazkii.botania:Botania:$botania_version:api")
runtimeOnly fg.deobf("vazkii.botania:Botania:$botania_version")
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title" : "electromana",
"Specification-Vendor" : "nuark",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.version,
"Implementation-Vendor" : "nuark",
"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-4.10.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
gradlew vendored Normal file
View file

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# 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
;;
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View file

@ -0,0 +1,84 @@
@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 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=
@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 init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
: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 %CMD_LINE_ARGS%
: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 = 'ElectroMana'

View file

@ -0,0 +1,40 @@
fc34001f56ccdf901b1e4b6868b1fd8823cb1d65 assets/electromana/blockstates/exquisite_mana_altar.json
25880ffbda8c120090630f93e049aea9a61ba53a assets/electromana/blockstates/greater_mana_altar.json
d17a596253235bc124b60a1d274694ab4712d758 assets/electromana/blockstates/lesser_mana_altar.json
14de5a2ca00f6042ca4ae23134d021e20018021b assets/electromana/blockstates/mana_transformer.json
06b8314324a3b297ec0526eaa4cfde52cd647846 assets/electromana/blockstates/mana_transformer_mk2.json
0c7c2951c1780184e9e8360bb5bb5a7048e9def5 assets/electromana/lang/en_us.json
5a7662a513336702499549af054d4ab93c3ac786 assets/electromana/models/block/exquisite_mana_altar.json
e44bbebffc4a41a346ecc2de19d4f3ff90ea7c95 assets/electromana/models/block/greater_mana_altar.json
17efee728cd3fa87e2de40f5785fcbc29a13eed3 assets/electromana/models/block/lesser_mana_altar.json
93f66170e29647ed2fb61aa53fa776c537866bd9 assets/electromana/models/block/mana_transformer.json
3337e8b56b3f8a58e2af6b01ba006bf1b6105dee assets/electromana/models/block/mana_transformer_mk2.json
fb6f49c561c954baa55ecdf314f063703334f90c assets/electromana/models/item/exquisite_mana_altar.json
2870b3cba0a892cef0bede4dcbff2cb10541a6a6 assets/electromana/models/item/greater_mana_altar.json
3303ab1db0e593d0c7f82ada8f2bb07cd172a163 assets/electromana/models/item/lesser_mana_altar.json
e25d5f927eb586ab9a473bc9c5fdc7681f389d8b assets/electromana/models/item/mana_transformer.json
8308adb6ac0fae9a742532bda2192bca35dfac6e assets/electromana/models/item/mana_transformer_mk2.json
e4e6e959a9856a03669d18890a4d626956664bae assets/electromana/models/item/reinforced_nether_star.json
0e80283003810968c48355c90dd0876475e84fd8 assets/electromana/models/item/reinforced_nether_star_piece.json
56ca4076dd581cfe45d4fee103e3a907fbdf98de assets/electromana/models/item/reinforced_plate.json
3ec95caae98f6533e1b76057f48be049763d0f48 data/electromana/advancements/recipes/electromana/exquisite_mana_altar.json
c5ecfe8b3eff83e243e7cb1bd8d2cdf0474b0b07 data/electromana/advancements/recipes/electromana/greater_mana_altar.json
7cc0a2332ec7515d9d2fac490667ccad227bc86c data/electromana/advancements/recipes/electromana/lesser_mana_altar.json
8fd1f37dd3228c7723d983f860cab7a39b0636bb data/electromana/advancements/recipes/electromana/mana_transformer.json
b575e20bb6d44a30067b7451e54edfa194c82971 data/electromana/advancements/recipes/electromana/mana_transformer_mk2.json
df4d565ee00fa4bc52c390995ee037a7fd54b51f data/electromana/advancements/recipes/electromana/reinforced_nether_star.json
3e564b34a8d7c1e5dc513d1bec1fdfed02debf88 data/electromana/advancements/recipes/electromana/reinforced_nether_star_piece.json
5db99dde40bb18c275bef16b0969632ed283d09e data/electromana/advancements/recipes/electromana/reinforced_plate.json
673469adf39785c71afdb0d2a2852f46c4bf2da0 data/electromana/loot_tables/blocks/exquisite_mana_altar.json
43c4a74271401d607308053cffcc51a3110f1e7b data/electromana/loot_tables/blocks/greater_mana_altar.json
510ceed371e14a5583d5616908d3f1b7f50af725 data/electromana/loot_tables/blocks/lesser_mana_altar.json
897cce21980e7d90d7a9194d99dddc2cb8c576e1 data/electromana/loot_tables/blocks/mana_transformer.json
0a40ef01b3286cf63081f788207c9e038c909ea3 data/electromana/loot_tables/blocks/mana_transformer_mk2.json
ffe0c79f7e04357196755f31d449564ebdcd6c82 data/electromana/recipes/exquisite_mana_altar.json
ade5957cec8d40bc305b14c4ccdba1174689c239 data/electromana/recipes/greater_mana_altar.json
c8c72bce25887a8612ded89485b66170407c12b2 data/electromana/recipes/lesser_mana_altar.json
46f2dea06029206f839201d9bd7bbc3eb5acf3c0 data/electromana/recipes/mana_transformer.json
f7a045d657a558ac4837d1186ad657bbc27b5cf9 data/electromana/recipes/mana_transformer_mk2.json
8f89f67b162e69594bae0dd5b025e4f6e5ddd472 data/electromana/recipes/reinforced_nether_star.json
c3b635315ae25b0e4899f22add9694cd4946877a data/electromana/recipes/reinforced_nether_star_piece.json
27af7685a92151721edda80ce85ad266e708fd07 data/electromana/recipes/reinforced_plate.json

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,15 @@
{
"block.electromana.exquisite_mana_altar": "Exquisite Mana Altar",
"block.electromana.greater_mana_altar": "Greater Mana Altar",
"block.electromana.lesser_mana_altar": "Lesser Mana Altar",
"block.electromana.mana_transformer": "Mana Transformer",
"block.electromana.mana_transformer_mk2": "Mana Transformer MK2",
"item.electromana.reinforced_nether_star": "Reinforced Nether Star",
"item.electromana.reinforced_nether_star_piece": "Reinforced Nether Star Piece",
"item.electromana.reinforced_plate": "Reinforced Plate",
"itemGroup.electromana": "ElectroMana",
"screen.electromana.burn_time": "Burn time left: %ss",
"screen.electromana.energy": "Energy: %s/%s FE",
"screen.electromana.mana": "Mana: %s/%s",
"screen.electromana.no_fuel": "Fuel source empty"
}

View file

@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "electromana:blocks/exquisite_mana_altar_side",
"front": "electromana:blocks/exquisite_mana_altar_front",
"bottom": "electromana:blocks/exquisite_mana_altar_side",
"top": "electromana:blocks/exquisite_mana_altar_side"
}
}

View file

@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "electromana:blocks/greater_mana_altar_side",
"front": "electromana:blocks/greater_mana_altar_front",
"bottom": "electromana:blocks/greater_mana_altar_side",
"top": "electromana:blocks/greater_mana_altar_side"
}
}

View file

@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "electromana:blocks/lesser_mana_altar_side",
"front": "electromana:blocks/lesser_mana_altar_front",
"bottom": "electromana:blocks/lesser_mana_altar_side",
"top": "electromana:blocks/lesser_mana_altar_side"
}
}

View file

@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "electromana:blocks/mana_transformer_side",
"front": "electromana:blocks/mana_transformer_side",
"bottom": "electromana:blocks/mana_transformer_side",
"top": "electromana:blocks/mana_transformer_side"
}
}

View file

@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "electromana:blocks/mana_transformer_mk2_side",
"front": "electromana:blocks/mana_transformer_mk2_side",
"bottom": "electromana:blocks/mana_transformer_mk2_side",
"top": "electromana:blocks/mana_transformer_mk2_side"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "electromana:block/exquisite_mana_altar"
}

View file

@ -0,0 +1,3 @@
{
"parent": "electromana:block/greater_mana_altar"
}

View file

@ -0,0 +1,3 @@
{
"parent": "electromana:block/lesser_mana_altar"
}

View file

@ -0,0 +1,3 @@
{
"parent": "electromana:block/mana_transformer"
}

View file

@ -0,0 +1,3 @@
{
"parent": "electromana:block/mana_transformer_mk2"
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "electromana:items/reinforced_nether_star"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "electromana:items/reinforced_nether_star_piece"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "electromana:items/reinforced_plate"
}
}

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:exquisite_mana_altar"
]
},
"criteria": {
"mana_altar_greater": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:greater_mana_altar"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:exquisite_mana_altar"
}
}
},
"requirements": [
[
"mana_altar_greater",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:greater_mana_altar"
]
},
"criteria": {
"mana_altar_lesser": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:lesser_mana_altar"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:greater_mana_altar"
}
}
},
"requirements": [
[
"mana_altar_lesser",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:lesser_mana_altar"
]
},
"criteria": {
"mana_mk2": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:mana_transformer_mk2"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:lesser_mana_altar"
}
}
},
"requirements": [
[
"mana_mk2",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:mana_transformer"
]
},
"criteria": {
"created_reinforced_nether_star_and_pieces": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:reinforced_nether_star"
},
{
"item": "electromana:reinforced_nether_star_piece"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:mana_transformer"
}
}
},
"requirements": [
[
"created_reinforced_nether_star_and_pieces",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:mana_transformer_mk2"
]
},
"criteria": {
"mana_mk1": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:mana_transformer"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:mana_transformer_mk2"
}
}
},
"requirements": [
[
"mana_mk1",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:reinforced_nether_star"
]
},
"criteria": {
"killed_wither_mined_scrap": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "minecraft:netherite_scrap"
},
{
"item": "minecraft:nether_star"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:reinforced_nether_star"
}
}
},
"requirements": [
[
"killed_wither_mined_scrap",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:reinforced_nether_star_piece"
]
},
"criteria": {
"created_reinforced_nether_star": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:reinforced_nether_star"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:reinforced_nether_star_piece"
}
}
},
"requirements": [
[
"created_reinforced_nether_star",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"electromana:reinforced_plate"
]
},
"criteria": {
"created_reinforced_nether_star_and_pieces": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "electromana:reinforced_nether_star"
},
{
"item": "electromana:reinforced_nether_star_piece"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "electromana:reinforced_plate"
}
}
},
"requirements": [
[
"created_reinforced_nether_star_and_pieces",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "electromana:exquisite_mana_altar",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "electromana:lesser_mana_altar"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "electromana:greater_mana_altar",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "electromana:lesser_mana_altar"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "electromana:lesser_mana_altar",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "electromana:lesser_mana_altar"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "electromana:mana_transformer",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "electromana:mana_transformer"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "electromana:mana_transformer_mk2",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "electromana:mana_transformer_mk2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"ppp",
"pcp",
"ttt"
],
"key": {
"c": {
"item": "electromana:reinforced_nether_star"
},
"t": {
"item": "electromana:greater_mana_altar"
},
"p": {
"item": "electromana:reinforced_plate"
}
},
"result": {
"item": "electromana:exquisite_mana_altar"
}
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"ppp",
"pcp",
"ttt"
],
"key": {
"c": {
"item": "electromana:reinforced_nether_star"
},
"t": {
"item": "electromana:lesser_mana_altar"
},
"p": {
"item": "electromana:reinforced_plate"
}
},
"result": {
"item": "electromana:greater_mana_altar"
}
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"ppp",
"pcp",
"ttt"
],
"key": {
"c": {
"item": "electromana:reinforced_nether_star"
},
"t": {
"item": "electromana:mana_transformer_mk2"
},
"p": {
"item": "electromana:reinforced_plate"
}
},
"result": {
"item": "electromana:lesser_mana_altar"
}
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"iii",
"dcd",
"iii"
],
"key": {
"i": {
"item": "electromana:reinforced_nether_star_piece"
},
"c": {
"item": "electromana:reinforced_nether_star"
},
"d": {
"item": "electromana:reinforced_plate"
}
},
"result": {
"item": "electromana:mana_transformer"
}
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"tpt",
"pcp",
"tpt"
],
"key": {
"t": {
"item": "electromana:mana_transformer"
},
"p": {
"item": "electromana:reinforced_nether_star_piece"
},
"c": {
"item": "electromana:reinforced_nether_star"
}
},
"result": {
"item": "electromana:mana_transformer_mk2"
}
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"sss",
"scs",
"sss"
],
"key": {
"s": {
"item": "minecraft:netherite_scrap"
},
"c": {
"item": "minecraft:nether_star"
}
},
"result": {
"item": "electromana:reinforced_nether_star"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shapeless",
"group": "electromana",
"ingredients": [
{
"item": "electromana:reinforced_nether_star"
},
{
"item": "minecraft:gunpowder"
},
{
"item": "minecraft:flint"
}
],
"result": {
"item": "electromana:reinforced_nether_star_piece",
"count": 2
}
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"group": "electromana",
"pattern": [
"isi",
"scs",
"isi"
],
"key": {
"s": {
"item": "electromana:reinforced_nether_star_piece"
},
"c": {
"item": "electromana:reinforced_nether_star"
},
"i": {
"item": "minecraft:iron_ingot"
}
},
"result": {
"item": "electromana:reinforced_plate"
}
}

View file

@ -0,0 +1,37 @@
package xyz.nuark.mods.electromana;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import xyz.nuark.mods.electromana.setup.ClientSetup;
import xyz.nuark.mods.electromana.setup.Config;
import xyz.nuark.mods.electromana.setup.ModSetup;
import xyz.nuark.mods.electromana.setup.Registration;
@Mod(ElectroMana.ID)
public class ElectroMana {
public static final String ID = "electromana";
public static final String NAME = "ElectroMana";
private static final Logger LOGGER = LogManager.getLogger();
public ElectroMana() {
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_CONFIG);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.SERVER_CONFIG);
Registration.init();
FMLJavaModLoadingContext.get().getModEventBus().addListener(ModSetup::init);
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::init);
MinecraftForge.EVENT_BUS.register(this);
}
public static Logger getLOGGER() {
return LOGGER;
}
}

View file

@ -0,0 +1,30 @@
package xyz.nuark.mods.electromana;
import net.minecraft.block.Block;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import xyz.nuark.mods.electromana.block.ExquisiteManaAltarBlock;
import xyz.nuark.mods.electromana.block.GreaterManaAltarBlock;
import xyz.nuark.mods.electromana.block.LesserManaAltarBlock;
import xyz.nuark.mods.electromana.block.ManaTransformerBlock;
import xyz.nuark.mods.electromana.block.ManaTransformerMK2Block;
public class ElectroManaBlocks {
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ElectroMana.ID);
public static final RegistryObject<Block> MANA_TRANSFORMER = BLOCKS.register("mana_transformer", ManaTransformerBlock::new);
public static final RegistryObject<Block> MANA_TRANSFORMER_MK2 = BLOCKS.register("mana_transformer_mk2", ManaTransformerMK2Block::new);
public static final RegistryObject<Block> LESSER_MANA_ALTAR = BLOCKS.register("lesser_mana_altar", LesserManaAltarBlock::new);
public static final RegistryObject<Block> GREATER_MANA_ALTAR = BLOCKS.register("greater_mana_altar", GreaterManaAltarBlock::new);
public static final RegistryObject<Block> EXQUISITE_MANA_ALTAR = BLOCKS.register("exquisite_mana_altar", ExquisiteManaAltarBlock::new);
public static void register() {
BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}

View file

@ -0,0 +1,20 @@
package xyz.nuark.mods.electromana;
import net.minecraft.inventory.container.ContainerType;
import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import xyz.nuark.mods.electromana.container.ManaTransformerContainer;
public class ElectroManaContainers {
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ElectroMana.ID);
public static final RegistryObject<ContainerType<ManaTransformerContainer>> MANA_TRANSFORMER_CONTAINER =
CONTAINERS.register("mana_transformer_container", () -> IForgeContainerType.create(ManaTransformerContainer::new));
public static void register() {
CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}

View file

@ -0,0 +1,71 @@
package xyz.nuark.mods.electromana;
import net.minecraft.item.Item;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import xyz.nuark.mods.electromana.item.ManaTransformerItem;
import xyz.nuark.mods.electromana.item.ReinforcedNetherStarItem;
import xyz.nuark.mods.electromana.item.ReinforcedNetherStarPieceItem;
import xyz.nuark.mods.electromana.item.ReinforcedPlateItem;
import xyz.nuark.mods.electromana.setup.ModSetup;
public class ElectroManaItems {
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ElectroMana.ID);
public static final RegistryObject<Item> MANA_TRANSFORMER_ITEM =
ITEMS.register(
"mana_transformer",
() -> new ManaTransformerItem(ElectroManaBlocks.MANA_TRANSFORMER.get(), ModSetup.ITEM_PROPS)
);
public static final RegistryObject<Item> MANA_TRANSFORMER_ITEM_MK2 =
ITEMS.register(
"mana_transformer_mk2",
() -> new ManaTransformerItem(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get(), ModSetup.ITEM_PROPS)
);
public static final RegistryObject<Item> LESSER_MANA_ALTAR_ITEM =
ITEMS.register(
"lesser_mana_altar",
() -> new ManaTransformerItem(ElectroManaBlocks.LESSER_MANA_ALTAR.get(), ModSetup.ITEM_PROPS)
);
public static final RegistryObject<Item> GREATER_MANA_ALTAR_ITEM =
ITEMS.register(
"greater_mana_altar",
() -> new ManaTransformerItem(ElectroManaBlocks.GREATER_MANA_ALTAR.get(), ModSetup.ITEM_PROPS)
);
public static final RegistryObject<Item> EXQUISITE_MANA_ALTAR_ITEM =
ITEMS.register(
"exquisite_mana_altar",
() -> new ManaTransformerItem(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get(), ModSetup.ITEM_PROPS)
);
public static final RegistryObject<Item> REINFORCED_NETHER_STAR =
ITEMS.register(
"reinforced_nether_star",
ReinforcedNetherStarItem::new
);
public static final RegistryObject<Item> REINFORCED_NETHER_STAR_PIECE =
ITEMS.register(
"reinforced_nether_star_piece",
ReinforcedNetherStarPieceItem::new
);
public static final RegistryObject<Item> REINFORCED_PLATE =
ITEMS.register(
"reinforced_plate",
ReinforcedPlateItem::new
);
public static void register() {
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}

View file

@ -0,0 +1,178 @@
package xyz.nuark.mods.electromana;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.registries.ForgeRegistries;
import xyz.nuark.mods.electromana.structure.BlockArray;
import xyz.nuark.mods.electromana.structure.StructureType;
public class ElectroManaStructures {
public static final StructureType LESSER_MANA_ALTAR_STRUCTURE = new StructureType(
new ResourceLocation(ElectroMana.ID, "lesser_mana_altar"),
new BlockPos(2,3,2),
() -> {
BlockArray struct = new BlockArray(5, 4);
Block a = null;
Block c = ElectroManaBlocks.LESSER_MANA_ALTAR.get();
Block p = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:mana_pylon"));
Block s = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:manasteel_block"));
Block d = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:mana_diamond_block"));
Block[][][] blocksMatrix = {
{
{s,s,s,s,s},
{s,s,s,s,s},
{s,s,d,s,s},
{s,s,s,s,s},
{s,s,s,s,s},
},
{
{p,a,a,a,p},
{a,d,d,d,a},
{a,d,d,d,a},
{a,d,d,d,a},
{p,a,a,a,p},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,d,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,c,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
}
};
for (int y = 0; y < blocksMatrix.length; y++) {
for (int x = 0; x < blocksMatrix[y].length; x++) {
for (int z = 0; z < blocksMatrix[y][x].length; z++) {
struct.addBlock(blocksMatrix[y][x][z], x, y, z);
}
}
}
return struct;
}
);
public static final StructureType GREATER_MANA_ALTAR_STRUCTURE = new StructureType(
new ResourceLocation(ElectroMana.ID, "greater_mana_altar"),
new BlockPos(2,3,2),
() -> {
BlockArray struct = new BlockArray(5, 4);
Block a = null;
Block c = ElectroManaBlocks.GREATER_MANA_ALTAR.get();
Block p = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:natura_pylon"));
Block t = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:terrasteel_block"));
Block s = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:manasteel_block"));
Block d = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:mana_diamond_block"));
Block[][][] blocksMatrix = {
{
{s,s,s,s,s},
{s,s,s,s,s},
{s,s,d,s,s},
{s,s,s,s,s},
{s,s,s,s,s},
},
{
{p,a,a,a,p},
{a,t,t,t,a},
{a,t,d,t,a},
{a,t,t,t,a},
{p,a,a,a,p},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,d,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,c,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
}
};
for (int y = 0; y < blocksMatrix.length; y++) {
for (int x = 0; x < blocksMatrix[y].length; x++) {
for (int z = 0; z < blocksMatrix[y][x].length; z++) {
struct.addBlock(blocksMatrix[y][x][z], x, y, z);
}
}
}
return struct;
}
);
public static final StructureType EXQUISITE_MANA_ALTAR_STRUCTURE = new StructureType(
new ResourceLocation(ElectroMana.ID, "exquisite_mana_altar"),
new BlockPos(2,3,2),
() -> {
BlockArray struct = new BlockArray(5, 4);
Block a = null;
Block c = ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get();
Block p = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:gaia_pylon"));
Block t = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:terrasteel_block"));
Block e = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:elementium_block"));
Block d = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("botania:mana_diamond_block"));
Block[][][] blocksMatrix = {
{
{t,t,t,t,t},
{t,t,t,t,t},
{t,t,d,t,t},
{t,t,t,t,t},
{t,t,t,t,t},
},
{
{p,a,a,a,p},
{a,e,e,e,a},
{a,e,d,e,a},
{a,e,e,e,a},
{p,a,a,a,p},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,d,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
},
{
{a,a,a,a,a},
{a,a,a,a,a},
{a,a,c,a,a},
{a,a,a,a,a},
{a,a,a,a,a},
}
};
for (int y = 0; y < blocksMatrix.length; y++) {
for (int x = 0; x < blocksMatrix[y].length; x++) {
for (int z = 0; z < blocksMatrix[y][x].length; z++) {
struct.addBlock(blocksMatrix[y][x][z], x, y, z);
}
}
}
return struct;
}
);
}

View file

@ -0,0 +1,50 @@
package xyz.nuark.mods.electromana;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import xyz.nuark.mods.electromana.tile.ExquisiteManaAltarTile;
import xyz.nuark.mods.electromana.tile.GreaterManaAltarTile;
import xyz.nuark.mods.electromana.tile.LesserManaAltarTile;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
import xyz.nuark.mods.electromana.tile.ManaTransformerMK2Tile;
public class ElectroManaTiles {
private static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ElectroMana.ID);
public static final RegistryObject<TileEntityType<ManaTransformerTile>> MANA_TRANSFORMER_TILE =
TILES.register(
"mana_transformer_tile",
() -> TileEntityType.Builder.create(ManaTransformerTile::new, ElectroManaBlocks.MANA_TRANSFORMER.get()).build(null)
);
public static final RegistryObject<TileEntityType<ManaTransformerMK2Tile>> MANA_TRANSFORMER_TILE_MK2 =
TILES.register(
"mana_transformer_tile_mk2",
() -> TileEntityType.Builder.create(ManaTransformerMK2Tile::new, ElectroManaBlocks.MANA_TRANSFORMER_MK2.get()).build(null)
);
public static final RegistryObject<TileEntityType<LesserManaAltarTile>> LESSER_MANA_ALTAR_TILE =
TILES.register(
"lesser_mana_altar_tile",
() -> TileEntityType.Builder.create(LesserManaAltarTile::new, ElectroManaBlocks.LESSER_MANA_ALTAR.get()).build(null)
);
public static final RegistryObject<TileEntityType<GreaterManaAltarTile>> GREATER_MANA_ALTAR_TILE =
TILES.register(
"greater_mana_altar_tile",
() -> TileEntityType.Builder.create(GreaterManaAltarTile::new, ElectroManaBlocks.GREATER_MANA_ALTAR.get()).build(null)
);
public static final RegistryObject<TileEntityType<ExquisiteManaAltarTile>> EXQUISITE_MANA_ALTAR_TILE =
TILES.register(
"exquisite_mana_altar_tile",
() -> TileEntityType.Builder.create(ExquisiteManaAltarTile::new, ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get()).build(null)
);
public static void register() {
TILES.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}

View file

@ -0,0 +1,92 @@
package xyz.nuark.mods.electromana.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import xyz.nuark.mods.electromana.ElectroManaItems;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.tile.ExquisiteManaAltarTile;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nullable;
import java.util.UUID;
public class ExquisiteManaAltarBlock extends Block {
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public ExquisiteManaAltarBlock() {
super(Properties.create(Material.IRON, MaterialColor.RED_TERRACOTTA)
.hardnessAndResistance(0.3F)
.sound(SoundType.METAL)
.setLightLevel((state) -> 15)
.harvestLevel(1)
.harvestTool(ToolType.PICKAXE)
);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
@SuppressWarnings("deprecation")
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
}
TileEntity te = worldIn.getTileEntity(pos);
if (!(te instanceof ExquisiteManaAltarTile))
return ActionResultType.FAIL;
UUID block_uuid = UUID.randomUUID();
if (player.getHeldItemOffhand().getItem() == ElectroManaItems.REINFORCED_PLATE.get()) {
player.sendMessage(new StringTextComponent(((ExquisiteManaAltarTile) te).hasMultiblock()? "Formed" : "Not formed"), block_uuid);
}
else {
try {
((ExquisiteManaAltarTile) te).validateMultiblock();
player.sendMessage(new StringTextComponent("Structure is formed correctly"), block_uuid);
} catch (BrokenStructureException e) {
player.sendMessage(new StringTextComponent(e.getMessage()), block_uuid);
}
}
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ElectroManaTiles.EXQUISITE_MANA_ALTAR_TILE.get().create();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
}

View file

@ -0,0 +1,93 @@
package xyz.nuark.mods.electromana.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import xyz.nuark.mods.electromana.ElectroManaItems;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.tile.ExquisiteManaAltarTile;
import xyz.nuark.mods.electromana.tile.GreaterManaAltarTile;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nullable;
import java.util.UUID;
public class GreaterManaAltarBlock extends Block {
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public GreaterManaAltarBlock() {
super(Properties.create(Material.IRON, MaterialColor.ORANGE_TERRACOTTA)
.hardnessAndResistance(0.3F)
.sound(SoundType.METAL)
.setLightLevel((state) -> 15)
.harvestLevel(1)
.harvestTool(ToolType.PICKAXE)
);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
@SuppressWarnings("deprecation")
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
}
TileEntity te = worldIn.getTileEntity(pos);
if (!(te instanceof GreaterManaAltarTile))
return ActionResultType.FAIL;
UUID block_uuid = UUID.randomUUID();
if (player.getHeldItemOffhand().getItem() == ElectroManaItems.REINFORCED_PLATE.get()) {
player.sendMessage(new StringTextComponent(((GreaterManaAltarTile) te).hasMultiblock()? "Formed" : "Not formed"), block_uuid);
}
else {
try {
((GreaterManaAltarTile) te).validateMultiblock();
player.sendMessage(new StringTextComponent("Structure is formed correctly"), block_uuid);
} catch (BrokenStructureException e) {
player.sendMessage(new StringTextComponent(e.getMessage()), block_uuid);
}
}
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ElectroManaTiles.GREATER_MANA_ALTAR_TILE.get().create();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
}

View file

@ -0,0 +1,90 @@
package xyz.nuark.mods.electromana.block;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import xyz.nuark.mods.electromana.ElectroManaItems;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.tile.ExquisiteManaAltarTile;
import xyz.nuark.mods.electromana.tile.LesserManaAltarTile;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nullable;
import java.util.UUID;
public class LesserManaAltarBlock extends Block {
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public LesserManaAltarBlock() {
super(AbstractBlock.Properties.create(Material.IRON, MaterialColor.YELLOW_TERRACOTTA)
.hardnessAndResistance(0.3F)
.sound(SoundType.METAL)
.setLightLevel((state) -> 15)
.harvestLevel(1)
.harvestTool(ToolType.PICKAXE)
);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
@SuppressWarnings("deprecation")
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
}
TileEntity te = worldIn.getTileEntity(pos);
if (!(te instanceof LesserManaAltarTile))
return ActionResultType.FAIL;
UUID block_uuid = UUID.randomUUID();
if (player.getHeldItemOffhand().getItem() == ElectroManaItems.REINFORCED_PLATE.get()) {
player.sendMessage(new StringTextComponent(((LesserManaAltarTile) te).hasMultiblock()? "Formed" : "Not formed"), block_uuid);
}
else {
try {
((LesserManaAltarTile) te).validateMultiblock();
player.sendMessage(new StringTextComponent("Structure is formed correctly"), block_uuid);
} catch (BrokenStructureException e) {
player.sendMessage(new StringTextComponent(e.getMessage()), block_uuid);
}
}
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ElectroManaTiles.LESSER_MANA_ALTAR_TILE.get().create();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
}

View file

@ -0,0 +1,116 @@
package xyz.nuark.mods.electromana.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.item.ManaTransformerItem;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
import javax.annotation.Nullable;
import java.util.List;
public class ManaTransformerBlock extends Block {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public ManaTransformerBlock() {
super(Properties.create(Material.IRON).hardnessAndResistance(1.9F).sound(SoundType.METAL));
setDefaultState(getStateContainer().getBaseState().with(FACING, Direction.NORTH));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity te = builder.get(LootParameters.BLOCK_ENTITY);
List<ItemStack> drops = super.getDrops(state, builder);
if (te instanceof ManaTransformerTile) {
ManaTransformerTile tileEntity = (ManaTransformerTile) te;
drops.stream()
.filter(e -> e.getItem() instanceof ManaTransformerItem)
.findFirst()
.ifPresent(e -> e.getOrCreateTag().putInt("energy", tileEntity.energyStorage.getEnergyStored()));
}
return drops;
}
@Override
@SuppressWarnings("deprecation")
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (newState.getBlock() != this) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity != null) {
LazyOptional<IItemHandler> cap = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
cap.ifPresent(handler -> {
for (int i = 0; i < handler.getSlots(); i++)
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
});
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@Override
@SuppressWarnings("deprecation")
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
}
TileEntity te = worldIn.getTileEntity(pos);
if (!(te instanceof ManaTransformerTile))
return ActionResultType.FAIL;
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) te, pos);
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ElectroManaTiles.MANA_TRANSFORMER_TILE.get().create();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
}

View file

@ -0,0 +1,116 @@
package xyz.nuark.mods.electromana.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.item.ManaTransformerItem;
import xyz.nuark.mods.electromana.tile.ManaTransformerMK2Tile;
import javax.annotation.Nullable;
import java.util.List;
public class ManaTransformerMK2Block extends Block {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public ManaTransformerMK2Block() {
super(Properties.create(Material.IRON).hardnessAndResistance(1.9F).sound(SoundType.METAL));
setDefaultState(getStateContainer().getBaseState().with(FACING, Direction.NORTH));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity te = builder.get(LootParameters.BLOCK_ENTITY);
List<ItemStack> drops = super.getDrops(state, builder);
if (te instanceof ManaTransformerMK2Tile) {
ManaTransformerMK2Tile tileEntity = (ManaTransformerMK2Tile) te;
drops.stream()
.filter(e -> e.getItem() instanceof ManaTransformerItem)
.findFirst()
.ifPresent(e -> e.getOrCreateTag().putInt("energy", tileEntity.energyStorage.getEnergyStored()));
}
return drops;
}
@Override
@SuppressWarnings("deprecation")
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (newState.getBlock() != this) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity != null) {
LazyOptional<IItemHandler> cap = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
cap.ifPresent(handler -> {
for (int i = 0; i < handler.getSlots(); i++)
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
});
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@Override
@SuppressWarnings("deprecation")
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
}
TileEntity te = worldIn.getTileEntity(pos);
if (!(te instanceof ManaTransformerMK2Tile))
return ActionResultType.FAIL;
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) te, pos);
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ElectroManaTiles.MANA_TRANSFORMER_TILE_MK2.get().create();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
}

View file

@ -0,0 +1,82 @@
package xyz.nuark.mods.electromana.capabilities;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.energy.IEnergyStorage;
import xyz.nuark.mods.electromana.tile.BaseManaAltarTile;
public class ManaAltarEnergyStorage implements IEnergyStorage, INBTSerializable<CompoundNBT> {
private static final String KEY = "energy";
private int energy;
private final int capacity = 5_000_000;
private final int maxInOut = 1_000_000;
private BaseManaAltarTile tile;
public ManaAltarEnergyStorage(BaseManaAltarTile tile, int energy) {
this.tile = tile;
this.energy = energy;
}
@Override
public CompoundNBT serializeNBT() {
CompoundNBT tag = new CompoundNBT();
tag.putInt(KEY, this.energy);
return tag;
}
@Override
public void deserializeNBT(CompoundNBT nbt) {
this.energy = nbt.getInt(KEY);
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(capacity - energy, Math.min(this.maxInOut, maxReceive));
if (!simulate) {
energy += energyReceived;
this.tile.markDirty();
}
return energyReceived;
}
public int consumeEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(energy, Math.min(this.maxInOut, maxExtract));
if (!simulate)
energy -= energyExtracted;
return energyExtracted;
}
public void setEnergy(int energy) {
this.energy = energy;
}
// We don't use this method and thus we don't let other people use it either
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int getEnergyStored() {
return this.energy;
}
@Override
public int getMaxEnergyStored() {
return this.capacity;
}
@Override
public boolean canExtract() {
return false;
}
@Override
public boolean canReceive() {
return true;
}
}

View file

@ -0,0 +1,36 @@
package xyz.nuark.mods.electromana.capabilities;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.items.ItemStackHandler;
import xyz.nuark.mods.electromana.tile.BaseManaTransformerTile;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
import javax.annotation.Nonnull;
public class ManaTransformerItemHandler extends ItemStackHandler {
private final BaseManaTransformerTile tile;
public ManaTransformerItemHandler(BaseManaTransformerTile tile) {
super(2);
this.tile = tile;
}
@Override
protected void onContentsChanged(int slot) {
tile.markDirty();
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (slot == BaseManaTransformerTile.Slots.FUEL.getId() && stack.getItem() == Items.BUCKET)
return super.insertItem(slot, stack, simulate);
if (slot == BaseManaTransformerTile.Slots.FUEL.getId() && ForgeHooks.getBurnTime(stack) <= 0)
return stack;
return super.insertItem(slot, stack, simulate);
}
}

View file

@ -0,0 +1,94 @@
package xyz.nuark.mods.electromana.capabilities;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.energy.IEnergyStorage;
import xyz.nuark.mods.electromana.tile.BaseManaTransformerTile;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
public class ManaTransformerStorage implements IEnergyStorage, INBTSerializable<CompoundNBT> {
private static final String KEY = "energy";
private int energy;
private int capacity;
private int maxInOut = 1000000;
private BaseManaTransformerTile tile;
public ManaTransformerStorage(BaseManaTransformerTile tile, int energy, int capacity) {
this.energy = energy;
this.capacity = capacity;
this.tile = tile;
}
@Override
public CompoundNBT serializeNBT() {
CompoundNBT tag = new CompoundNBT();
tag.putInt(KEY, this.energy);
return tag;
}
@Override
public void deserializeNBT(CompoundNBT nbt) {
this.energy = nbt.getInt(KEY);
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(capacity - energy, Math.min(this.maxInOut, maxReceive));
if (!simulate) {
energy += energyReceived;
this.tile.markDirty();
}
return energyReceived;
}
public int consumeEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(energy, Math.min(this.maxInOut, maxExtract));
if (!simulate)
energy -= energyExtracted;
return energyExtracted;
}
public void setEnergy(int energy) {
this.energy = energy;
}
// We don't use this method and thus we don't let other people use it either
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int getEnergyStored() {
return this.energy;
}
@Override
public int getMaxEnergyStored() {
return this.capacity;
}
@Override
public boolean canExtract() {
return false;
}
@Override
public boolean canReceive() {
return true;
}
@Override
public String toString() {
return "ManaTransformerStorage{" +
"energy=" + energy +
", capacity=" + capacity +
", maxInOut=" + maxInOut +
", tile=" + tile +
'}';
}
}

View file

@ -0,0 +1,112 @@
package xyz.nuark.mods.electromana.client.screens;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.LanguageMap;
import net.minecraft.util.text.TranslationTextComponent;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.container.ManaTransformerContainer;
import xyz.nuark.mods.electromana.utils.MathUtils;
import xyz.nuark.mods.electromana.utils.StringHelpers;
import java.awt.*;
import java.util.Arrays;
public class ManaTransformerScreen extends ContainerScreen<ManaTransformerContainer> {
private static final ResourceLocation background = new ResourceLocation(ElectroMana.ID, "textures/gui/mana_transformer.png");
private final ManaTransformerContainer container;
public ManaTransformerScreen(ManaTransformerContainer container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
this.container = container;
}
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(stack);
super.render(stack, mouseX, mouseY, partialTicks);
this.renderHoveredTooltip(stack, mouseX, mouseY);
if (MathUtils.inRect(mouseX, mouseY, guiLeft + 7, guiTop + 7, guiLeft + 7 + 18, guiTop + 7 + 73)) {
this.renderTooltip(stack, LanguageMap.getInstance().func_244260_a(Arrays.asList(
new TranslationTextComponent("screen.electromana.energy", StringHelpers.withSuffix(this.container.getEnergy()), StringHelpers.withSuffix(this.container.getMaxPower())),
this.container.getRemaining() <= 0 ?
new TranslationTextComponent("screen.electromana.no_fuel") :
new TranslationTextComponent("screen.electromana.burn_time", StringHelpers.ticksInSeconds(this.container.getRemaining()))
)), mouseX, mouseY);
}
if (MathUtils.inRect(mouseX, mouseY, guiLeft + 151, guiTop + 7, guiLeft + 151 + 18, guiTop + 7 + 73)) {
// TODO: MAYBE OLD WAY
// int[] poolInfo = this.container.getManaPoolInfo();
// this.renderTooltip(stack,
// new TranslationTextComponent("screen.electromana.mana", poolInfo[0], poolInfo[1]),
// mouseX, mouseY);
this.renderTooltip(stack,
new TranslationTextComponent("screen.electromana.mana", this.container.getCurrentMana(), this.container.getManaCap()),
mouseX, mouseY);
}
}
@Override
public void init() {
super.init();
}
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY) {
RenderSystem.color4f(1, 1, 1, 1);
getMinecraft().getTextureManager().bindTexture(background);
this.blit(stack, guiLeft, guiTop, 0, 0, xSize, ySize);
// Drawing fire
{
int posX = 81;
int posY = 45;
int maxHeight = 13;
if (this.container.getMaxBurn() > 0) {
int remaining = (this.container.getRemaining() * maxHeight) / this.container.getMaxBurn();
this.blit(stack, guiLeft + posX, guiTop + posY + 13 - remaining, 176, 13 - remaining, 14, remaining + 1);
}
}
// Drawing energy
{
int posX = 7;
int posY = 78;
int maxEnergy = this.container.getMaxPower(), height = 70;
if (maxEnergy > 0) {
int remaining = (this.container.getEnergy() * height) / maxEnergy;
this.blit(stack, guiLeft + posX, guiTop + posY - remaining, 176, 84 - remaining, 16, remaining + 1);
}
}
// Drawing mana
{
int posX = 151;
int posY = 78;
// TODO: MAYBE OLD WAY
// int[] poolInfo = this.container.getManaPoolInfo();
// int maxEnergy = poolInfo[1], height = 70;
// if (maxEnergy > 0) {
// int remaining = (poolInfo[0] * height) / maxEnergy;
// this.blit(stack, guiLeft + posX, guiTop + posY - remaining, 192, 84 - remaining, 16, remaining + 1);
// }
int maxEnergy = this.container.getManaCap(), height = 70;
if (maxEnergy > 0) {
int remaining = (this.container.getCurrentMana() * height) / maxEnergy;
this.blit(stack, guiLeft + posX, guiTop + posY - remaining, 192, 84 - remaining, 16, remaining + 1);
}
}
}
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY) {
Minecraft.getInstance().fontRenderer.drawString(stack, "Mana Transformer", 42, 8, Color.DARK_GRAY.getRGB());
}
}

View file

@ -0,0 +1,148 @@
package xyz.nuark.mods.electromana.container;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.IIntArray;
import net.minecraft.util.IntArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.SlotItemHandler;
import xyz.nuark.mods.electromana.ElectroManaContainers;
import xyz.nuark.mods.electromana.tile.BaseManaTransformerTile;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ManaTransformerContainer extends Container {
private static final int SLOTS = 1;
public final IIntArray data;
public ItemStackHandler handler;
private BaseManaTransformerTile tile;
public ManaTransformerContainer(int windowId, PlayerInventory playerInventory, PacketBuffer extraData) {
this((BaseManaTransformerTile) playerInventory.player.world.getTileEntity(extraData.readBlockPos()), new IntArray(6), windowId, playerInventory, new ItemStackHandler(2));
}
public ManaTransformerContainer(@Nullable BaseManaTransformerTile tile, IIntArray manaTransformerData, int windowId, PlayerInventory playerInventory, ItemStackHandler handler) {
super(ElectroManaContainers.MANA_TRANSFORMER_CONTAINER.get(), windowId);
this.handler = handler;
this.tile = tile;
this.data = manaTransformerData;
this.setup(playerInventory);
trackIntArray(manaTransformerData);
}
public void setup(PlayerInventory inventory) {
addSlot(new RestrictedSlot(handler, 0, 80, 62));
// Slots for the hotbar
for (int row = 0; row < 9; ++row) {
int x = 8 + row * 18;
int y = 56 + 86;
addSlot(new Slot(inventory, row, x, y));
}
// Slots for the main inventory
for (int row = 1; row < 4; ++row) {
for (int col = 0; col < 9; ++col) {
int x = 8 + col * 18;
int y = row * 18 + (56 + 10);
addSlot(new Slot(inventory, col + row * 9, x, y));
}
}
}
@Override
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack currentStack = slot.getStack();
itemstack = currentStack.copy();
if (index < SLOTS) {
if (!this.mergeItemStack(currentStack, SLOTS, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(currentStack, 0, SLOTS, false)) {
return ItemStack.EMPTY;
}
if (currentStack.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
@Override
public boolean canInteractWith(PlayerEntity playerIn) {
BlockPos pos = this.tile.getPos();
return this.tile != null && !this.tile.isRemoved() && playerIn.getDistanceSq(new Vector3d(pos.getX(), pos.getY(), pos.getZ()).add(0.5D, 0.5D, 0.5D)) <= 64D;
}
public int getMaxPower() {
return this.data.get(1) * 32;
}
public int getEnergy() {
return this.data.get(0) * 32;
}
public int getMaxBurn() {
return this.data.get(3);
}
public int getRemaining() {
return this.data.get(2);
}
public int getCurrentMana() {
return this.data.get(4);
}
public int getManaCap() {
return this.data.get(5);
}
// public int[] getManaPoolInfo() {
// int[] data = {0, 0};
//
// if (tile != null) {
// data = tile.getManaPoolInfo();
// }
//
// return data;
// }
static class RestrictedSlot extends SlotItemHandler {
public RestrictedSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition) {
super(itemHandler, index, xPosition, yPosition);
}
@Override
public boolean isItemValid(@Nonnull ItemStack stack) {
if (getSlotIndex() == ManaTransformerTile.Slots.FUEL.getId()) {
return ForgeHooks.getBurnTime(stack) != 0;
}
return super.isItemValid(stack);
}
}
}

View file

@ -0,0 +1,58 @@
package xyz.nuark.mods.electromana.data;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import java.util.Objects;
public class GeneratorBlockStates extends BlockStateProvider {
public GeneratorBlockStates(DataGenerator gen, ExistingFileHelper exFileHelper) {
super(gen, ElectroMana.ID, exFileHelper);
}
@Override
protected void registerStatesAndModels() {
horizontalBlock(ElectroManaBlocks.MANA_TRANSFORMER.get(), models().orientableWithBottom(
Objects.requireNonNull(ElectroManaBlocks.MANA_TRANSFORMER.get().getRegistryName()).getPath(),
modLoc("blocks/mana_transformer_side"),
modLoc("blocks/mana_transformer_side"),
modLoc("blocks/mana_transformer_side"),
modLoc("blocks/mana_transformer_side")
));
horizontalBlock(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get(), models().orientableWithBottom(
Objects.requireNonNull(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get().getRegistryName()).getPath(),
modLoc("blocks/mana_transformer_mk2_side"),
modLoc("blocks/mana_transformer_mk2_side"),
modLoc("blocks/mana_transformer_mk2_side"),
modLoc("blocks/mana_transformer_mk2_side")
));
horizontalBlock(ElectroManaBlocks.LESSER_MANA_ALTAR.get(), models().orientableWithBottom(
Objects.requireNonNull(ElectroManaBlocks.LESSER_MANA_ALTAR.get().getRegistryName()).getPath(),
modLoc("blocks/lesser_mana_altar_side"),
modLoc("blocks/lesser_mana_altar_front"),
modLoc("blocks/lesser_mana_altar_side"),
modLoc("blocks/lesser_mana_altar_side")
));
horizontalBlock(ElectroManaBlocks.GREATER_MANA_ALTAR.get(), models().orientableWithBottom(
Objects.requireNonNull(ElectroManaBlocks.GREATER_MANA_ALTAR.get().getRegistryName()).getPath(),
modLoc("blocks/greater_mana_altar_side"),
modLoc("blocks/greater_mana_altar_front"),
modLoc("blocks/greater_mana_altar_side"),
modLoc("blocks/greater_mana_altar_side")
));
horizontalBlock(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get(), models().orientableWithBottom(
Objects.requireNonNull(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get().getRegistryName()).getPath(),
modLoc("blocks/exquisite_mana_altar_side"),
modLoc("blocks/exquisite_mana_altar_front"),
modLoc("blocks/exquisite_mana_altar_side"),
modLoc("blocks/exquisite_mana_altar_side")
));
}
}

View file

@ -0,0 +1,41 @@
package xyz.nuark.mods.electromana.data;
import net.minecraft.data.DataGenerator;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.ItemModelBuilder;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import xyz.nuark.mods.electromana.ElectroManaItems;
public class GeneratorItemModels extends ItemModelProvider {
public GeneratorItemModels(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator, ElectroMana.ID, existingFileHelper);
}
@SuppressWarnings("ConstantConditions") // Like, I gurantee
@Override
protected void registerModels() {
generateBlockTexture(ElectroManaBlocks.MANA_TRANSFORMER.get().getRegistryName());
generateBlockTexture(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get().getRegistryName());
generateBlockTexture(ElectroManaBlocks.LESSER_MANA_ALTAR.get().getRegistryName());
generateBlockTexture(ElectroManaBlocks.GREATER_MANA_ALTAR.get().getRegistryName());
generateBlockTexture(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get().getRegistryName());
generateItemTexture(ElectroManaItems.REINFORCED_NETHER_STAR.get().getRegistryName());
generateItemTexture(ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get().getRegistryName());
generateItemTexture(ElectroManaItems.REINFORCED_PLATE.get().getRegistryName());
}
private void generateBlockTexture(ResourceLocation blockRegistryName) {
getBuilder(blockRegistryName.getPath()).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + blockRegistryName.getPath())));
}
private void generateItemTexture(ResourceLocation itemRegistryName) {
getBuilder(itemRegistryName.getPath())
.parent(new ModelFile.UncheckedModelFile(new ResourceLocation("minecraft", "item/generated")))
.texture("layer0", "items/" + itemRegistryName.getPath());
}
}

View file

@ -0,0 +1,30 @@
package xyz.nuark.mods.electromana.data;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.data.LanguageProvider;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import xyz.nuark.mods.electromana.ElectroManaItems;
public class GeneratorLanguage extends LanguageProvider {
public GeneratorLanguage(DataGenerator gen) {
super(gen, ElectroMana.ID, "en_us");
}
@Override
protected void addTranslations() {
addBlock(ElectroManaBlocks.MANA_TRANSFORMER, "Mana Transformer");
addBlock(ElectroManaBlocks.MANA_TRANSFORMER_MK2, "Mana Transformer MK2");
addBlock(ElectroManaBlocks.LESSER_MANA_ALTAR, "Lesser Mana Altar");
addBlock(ElectroManaBlocks.GREATER_MANA_ALTAR, "Greater Mana Altar");
addBlock(ElectroManaBlocks.EXQUISITE_MANA_ALTAR, "Exquisite Mana Altar");
addItem(ElectroManaItems.REINFORCED_NETHER_STAR, "Reinforced Nether Star");
addItem(ElectroManaItems.REINFORCED_NETHER_STAR_PIECE, "Reinforced Nether Star Piece");
addItem(ElectroManaItems.REINFORCED_PLATE, "Reinforced Plate");
add("itemGroup.electromana", "ElectroMana");
add("screen.electromana.energy", "Energy: %s/%s FE");
add("screen.electromana.mana", "Mana: %s/%s");
add("screen.electromana.no_fuel", "Fuel source empty");
add("screen.electromana.burn_time", "Burn time left: %ss");
}
}

View file

@ -0,0 +1,97 @@
package xyz.nuark.mods.electromana.data;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.LootTableProvider;
import net.minecraft.data.loot.BlockLootTables;
import net.minecraft.loot.*;
import net.minecraft.loot.conditions.SurvivesExplosion;
import net.minecraft.loot.functions.CopyName;
import net.minecraft.util.ResourceLocation;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class GeneratorLoots extends LootTableProvider {
public GeneratorLoots(DataGenerator dataGeneratorIn) {
super(dataGeneratorIn);
}
@Override
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables() {
return ImmutableList.of(Pair.of(Blocks::new, LootParameterSets.BLOCK));
}
private static class Blocks extends BlockLootTables {
@Override
protected void addTables() {
LootPool.Builder manaTransformer = LootPool.builder()
.name(ElectroManaBlocks.MANA_TRANSFORMER.get().getRegistryName().toString())
.rolls(ConstantRange.of(1))
.acceptCondition(SurvivesExplosion.builder())
.addEntry(ItemLootEntry.builder(ElectroManaBlocks.MANA_TRANSFORMER.get())
.acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY))
);
LootPool.Builder manaTransformerMK2 = LootPool.builder()
.name(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get().getRegistryName().toString())
.rolls(ConstantRange.of(1))
.acceptCondition(SurvivesExplosion.builder())
.addEntry(ItemLootEntry.builder(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get())
.acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY))
);
LootPool.Builder lesserManaAltar = LootPool.builder()
.name(ElectroManaBlocks.LESSER_MANA_ALTAR.get().getRegistryName().toString())
.rolls(ConstantRange.of(1))
.acceptCondition(SurvivesExplosion.builder())
.addEntry(ItemLootEntry.builder(ElectroManaBlocks.LESSER_MANA_ALTAR.get())
.acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY))
);
LootPool.Builder greaterManaAltar = LootPool.builder()
.name(ElectroManaBlocks.GREATER_MANA_ALTAR.get().getRegistryName().toString())
.rolls(ConstantRange.of(1))
.acceptCondition(SurvivesExplosion.builder())
.addEntry(ItemLootEntry.builder(ElectroManaBlocks.LESSER_MANA_ALTAR.get())
.acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY))
);
LootPool.Builder exquisiteManaAltar = LootPool.builder()
.name(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get().getRegistryName().toString())
.rolls(ConstantRange.of(1))
.acceptCondition(SurvivesExplosion.builder())
.addEntry(ItemLootEntry.builder(ElectroManaBlocks.LESSER_MANA_ALTAR.get())
.acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY))
);
this.registerLootTable(ElectroManaBlocks.MANA_TRANSFORMER.get(), LootTable.builder().addLootPool(manaTransformer));
this.registerLootTable(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get(), LootTable.builder().addLootPool(manaTransformerMK2));
this.registerLootTable(ElectroManaBlocks.LESSER_MANA_ALTAR.get(), LootTable.builder().addLootPool(lesserManaAltar));
this.registerLootTable(ElectroManaBlocks.GREATER_MANA_ALTAR.get(), LootTable.builder().addLootPool(greaterManaAltar));
this.registerLootTable(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get(), LootTable.builder().addLootPool(exquisiteManaAltar));
}
@Override
protected Iterable<Block> getKnownBlocks() {
return ImmutableList.of(
ElectroManaBlocks.MANA_TRANSFORMER.get(),
ElectroManaBlocks.MANA_TRANSFORMER_MK2.get(),
ElectroManaBlocks.LESSER_MANA_ALTAR.get(),
ElectroManaBlocks.GREATER_MANA_ALTAR.get(),
ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get()
);
}
}
@Override
protected void validate(Map<ResourceLocation, LootTable> map, ValidationTracker validationtracker) {
map.forEach((name, table) -> LootTableManager.validateLootTable(validationtracker, name, table));
}
}

View file

@ -0,0 +1,118 @@
package xyz.nuark.mods.electromana.data;
import net.minecraft.advancements.criterion.InventoryChangeTrigger;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Blocks;
import net.minecraft.block.DragonEggBlock;
import net.minecraft.data.*;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.common.Tags;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import xyz.nuark.mods.electromana.ElectroManaItems;
import javax.annotation.Nonnull;
import java.util.function.Consumer;
public class GeneratorRecipes extends RecipeProvider {
public GeneratorRecipes(DataGenerator generator) {
super(generator);
}
@Override
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
ShapedRecipeBuilder
.shapedRecipe(ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('s', Items.NETHERITE_SCRAP)
.key('c', Items.NETHER_STAR)
.patternLine("sss")
.patternLine("scs")
.patternLine("sss")
.setGroup(ElectroMana.ID)
.addCriterion("killed_wither_mined_scrap", InventoryChangeTrigger.Instance.forItems(Items.NETHERITE_SCRAP, Items.NETHER_STAR))
.build(consumer, ElectroManaItems.REINFORCED_NETHER_STAR.getId());
ShapelessRecipeBuilder
.shapelessRecipe(ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get(), 2)
.addIngredient(ElectroManaItems.REINFORCED_NETHER_STAR.get())
.addIngredient(Items.GUNPOWDER)
.addIngredient(Items.FLINT)
.setGroup(ElectroMana.ID)
.addCriterion("created_reinforced_nether_star", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.REINFORCED_NETHER_STAR.get()))
.build(consumer, ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaItems.REINFORCED_PLATE.get())
.key('s', ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('i', Items.IRON_INGOT)
.patternLine("isi")
.patternLine("scs")
.patternLine("isi")
.setGroup(ElectroMana.ID)
.addCriterion("created_reinforced_nether_star_and_pieces", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.REINFORCED_NETHER_STAR.get(), ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get()))
.build(consumer, ElectroManaItems.REINFORCED_PLATE.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaBlocks.MANA_TRANSFORMER.get())
.key('d', ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('i', ElectroManaItems.REINFORCED_PLATE.get())
.patternLine("iii")
.patternLine("dcd")
.patternLine("iii")
.setGroup(ElectroMana.ID)
.addCriterion("created_reinforced_nether_star_and_pieces", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.REINFORCED_NETHER_STAR.get(), ElectroManaItems.REINFORCED_NETHER_STAR_PIECE.get()))
.build(consumer, ElectroManaBlocks.MANA_TRANSFORMER.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaBlocks.MANA_TRANSFORMER_MK2.get())
.key('t', ElectroManaItems.MANA_TRANSFORMER_ITEM.get())
.key('p', ElectroManaItems.REINFORCED_PLATE.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.patternLine("tpt")
.patternLine("pcp")
.patternLine("tpt")
.setGroup(ElectroMana.ID)
.addCriterion("mana_mk1", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.MANA_TRANSFORMER_ITEM.get()))
.build(consumer, ElectroManaBlocks.MANA_TRANSFORMER_MK2.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaBlocks.LESSER_MANA_ALTAR.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('t', ElectroManaItems.MANA_TRANSFORMER_ITEM_MK2.get())
.key('p', ElectroManaItems.REINFORCED_PLATE.get())
.patternLine("ppp")
.patternLine("pcp")
.patternLine("ttt")
.setGroup(ElectroMana.ID)
.addCriterion("mana_mk2", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.MANA_TRANSFORMER_ITEM_MK2.get()))
.build(consumer, ElectroManaBlocks.LESSER_MANA_ALTAR.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaBlocks.GREATER_MANA_ALTAR.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('t', ElectroManaItems.LESSER_MANA_ALTAR_ITEM.get())
.key('p', ElectroManaItems.REINFORCED_PLATE.get())
.patternLine("ppp")
.patternLine("pcp")
.patternLine("ttt")
.setGroup(ElectroMana.ID)
.addCriterion("mana_altar_lesser", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.LESSER_MANA_ALTAR_ITEM.get()))
.build(consumer, ElectroManaBlocks.GREATER_MANA_ALTAR.getId());
ShapedRecipeBuilder
.shapedRecipe(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get())
.key('c', ElectroManaItems.REINFORCED_NETHER_STAR.get())
.key('t', ElectroManaItems.GREATER_MANA_ALTAR_ITEM.get())
.key('p', ElectroManaItems.REINFORCED_PLATE.get())
.patternLine("ppp")
.patternLine("pcp")
.patternLine("ttt")
.setGroup(ElectroMana.ID)
.addCriterion("mana_altar_greater", InventoryChangeTrigger.Instance.forItems(ElectroManaItems.GREATER_MANA_ALTAR_ITEM.get()))
.build(consumer, ElectroManaBlocks.EXQUISITE_MANA_ALTAR.getId());
}
}

View file

@ -0,0 +1,26 @@
package xyz.nuark.mods.electromana.data;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import xyz.nuark.mods.electromana.ElectroMana;
@Mod.EventBusSubscriber(modid= ElectroMana.ID, bus= Mod.EventBusSubscriber.Bus.MOD)
public class Generators {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
if (event.includeServer()) {
generator.addProvider(new GeneratorRecipes(generator));
generator.addProvider(new GeneratorLoots(generator));
}
if (event.includeClient()) {
generator.addProvider(new GeneratorLanguage(generator));
generator.addProvider(new GeneratorBlockStates(generator, event.getExistingFileHelper()));
generator.addProvider(new GeneratorItemModels(generator, event.getExistingFileHelper()));
}
}
}

View file

@ -0,0 +1,43 @@
package xyz.nuark.mods.electromana.item;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import xyz.nuark.mods.electromana.tile.ManaTransformerTile;
import javax.annotation.Nullable;
import java.util.List;
public class ManaTransformerItem extends BlockItem {
public ManaTransformerItem(Block blockIn, Properties builder) {
super(blockIn, builder);
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(new StringTextComponent("Transforming FE into Mana since 2021!").mergeStyle(TextFormatting.GREEN));
}
@Override
protected boolean onBlockPlaced(BlockPos pos, World worldIn, @Nullable PlayerEntity player, ItemStack stack, BlockState state) {
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof ManaTransformerTile) {
ManaTransformerTile tile = (ManaTransformerTile) te;
tile.energyStorage.receiveEnergy(stack.getOrCreateTag().getInt("energy"), false);
}
return super.onBlockPlaced(pos, worldIn, player, stack, state);
}
}

View file

@ -0,0 +1,23 @@
package xyz.nuark.mods.electromana.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.world.World;
import xyz.nuark.mods.electromana.setup.ModSetup;
public class ReinforcedNetherStarItem extends Item {
public ReinforcedNetherStarItem() {
super(ModSetup.ITEM_PROPS.rarity(Rarity.RARE).isImmuneToFire());
}
@Override
public int getEntityLifespan(ItemStack stack, World world) {
return Integer.MAX_VALUE;
}
@Override
public boolean hasEffect(ItemStack stack) {
return true;
}
}

View file

@ -0,0 +1,18 @@
package xyz.nuark.mods.electromana.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.world.World;
import xyz.nuark.mods.electromana.setup.ModSetup;
public class ReinforcedNetherStarPieceItem extends Item {
public ReinforcedNetherStarPieceItem() {
super(ModSetup.ITEM_PROPS.rarity(Rarity.RARE).isImmuneToFire());
}
@Override
public int getEntityLifespan(ItemStack stack, World world) {
return Integer.MAX_VALUE;
}
}

View file

@ -0,0 +1,23 @@
package xyz.nuark.mods.electromana.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.world.World;
import xyz.nuark.mods.electromana.setup.ModSetup;
public class ReinforcedPlateItem extends Item {
public ReinforcedPlateItem() {
super(ModSetup.ITEM_PROPS.rarity(Rarity.RARE).isImmuneToFire());
}
@Override
public int getEntityLifespan(ItemStack stack, World world) {
return Integer.MAX_VALUE;
}
@Override
public boolean hasEffect(ItemStack stack) {
return true;
}
}

View file

@ -0,0 +1,17 @@
package xyz.nuark.mods.electromana.setup;
import net.minecraft.client.gui.ScreenManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaContainers;
import xyz.nuark.mods.electromana.client.screens.ManaTransformerScreen;
@Mod.EventBusSubscriber(modid=ElectroMana.ID, value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
public class ClientSetup {
public static void init(final FMLClientSetupEvent event) {
ScreenManager.registerFactory(ElectroManaContainers.MANA_TRANSFORMER_CONTAINER.get(), ManaTransformerScreen::new);
}
}

View file

@ -0,0 +1,48 @@
package xyz.nuark.mods.electromana.setup;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
@Mod.EventBusSubscriber
public class Config {
public static ForgeConfigSpec SERVER_CONFIG;
public static ForgeConfigSpec CLIENT_CONFIG;
public static ForgeConfigSpec.IntValue CHARGE_MAX_POWER;
public static ForgeConfigSpec.IntValue CHARGE_MAX_POWER_MK2;
public static ForgeConfigSpec.IntValue GENERATION_MAX_MANA;
public static ForgeConfigSpec.IntValue GENERATION_MAX_MANA_MK2;
public static ForgeConfigSpec.IntValue POWER_USAGE;
public static ForgeConfigSpec.IntValue POWER_USAGE_MK2;
static {
ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder();
SERVER_BUILDER.comment("General settings").push("general");
CHARGE_MAX_POWER = SERVER_BUILDER.defineInRange("charge_max_power", 10000, 0, Integer.MAX_VALUE);
CHARGE_MAX_POWER_MK2 = SERVER_BUILDER.defineInRange("charge_max_power_mk2", 1000000000, 0, Integer.MAX_VALUE);
GENERATION_MAX_MANA = SERVER_BUILDER.defineInRange("generation_max_mana", 1, 0, Integer.MAX_VALUE);
GENERATION_MAX_MANA_MK2 = SERVER_BUILDER.defineInRange("generation_max_mana_mk2", 1000, 0, Integer.MAX_VALUE);
POWER_USAGE = SERVER_BUILDER.defineInRange("power_usage", 10000, 0, Integer.MAX_VALUE);
POWER_USAGE_MK2 = SERVER_BUILDER.defineInRange("power_usage_mk2", 1000, 0, Integer.MAX_VALUE);
SERVER_BUILDER.pop();
SERVER_CONFIG = SERVER_BUILDER.build();
CLIENT_CONFIG = CLIENT_BUILDER.build();
}
@SubscribeEvent
public static void onLoad(final ModConfig.Loading configEvent) {}
@SubscribeEvent
public static void onReload(final ModConfig.Reloading configEvent) {}
}

View file

@ -0,0 +1,27 @@
package xyz.nuark.mods.electromana.setup;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
@Mod.EventBusSubscriber(modid= ElectroMana.ID, value= Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.FORGE)
public class ModSetup {
public static final ItemGroup ITEM_GROUP = new ItemGroup(ElectroMana.ID) {
@Override
public ItemStack createIcon() {
return new ItemStack(ElectroManaBlocks.EXQUISITE_MANA_ALTAR.get());
}
};
public static final Item.Properties ITEM_PROPS = new Item.Properties().group(ITEM_GROUP);
public static void init(final FMLCommonSetupEvent event) {
}
}

View file

@ -0,0 +1,15 @@
package xyz.nuark.mods.electromana.setup;
import xyz.nuark.mods.electromana.ElectroManaBlocks;
import xyz.nuark.mods.electromana.ElectroManaContainers;
import xyz.nuark.mods.electromana.ElectroManaItems;
import xyz.nuark.mods.electromana.ElectroManaTiles;
public class Registration {
public static void init() {
ElectroManaItems.register();
ElectroManaBlocks.register();
ElectroManaTiles.register();
ElectroManaContainers.register();
}
}

View file

@ -0,0 +1,62 @@
package xyz.nuark.mods.electromana.structure;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class BlockArray {
Map<BlockPos, Block> _blocks;
int width, height;
public BlockArray(int width, int height) {
this.width = width;
this.height = height;
_blocks = new HashMap<>();
}
public void addBlock(Block block, BlockPos pos) {
_blocks.put(pos, block);
}
public void addBlock(Block block, int x, int y, int z) {
this.addBlock(block, new BlockPos(x, y, z));
}
boolean check(BlockPos realPos, BlockPos inStructPos, IWorld world) throws BrokenStructureException {
int startX = realPos.getX() - inStructPos.getX();
int startY = realPos.getY() - inStructPos.getY();
int startZ = realPos.getZ() - inStructPos.getZ();
for (int posX = 0; posX < width; posX++) {
for (int posZ = 0; posZ < width; posZ++) {
for (int posY = 0; posY < height; posY++) {
Block structBlock = _blocks.getOrDefault(new BlockPos(posX, posY, posZ), null);
BlockPos worldBlockPos = new BlockPos(startX + posX, startY + posY, startZ + posZ);
Block worldBlock = world.getBlockState(worldBlockPos)
.getBlock();
if (structBlock == null) {
continue;
}
if (structBlock != worldBlock) {
String message = String.format(
Locale.CANADA, "Required '%s' at [x=%d, y=%d, z=%d], but found '%s'",
structBlock.getTranslatedName().getString(), worldBlockPos.getX(), worldBlockPos.getY(),
worldBlockPos.getZ(), worldBlock.getTranslatedName().getString()
);
throw new BrokenStructureException(message);
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,54 @@
package xyz.nuark.mods.electromana.structure;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import xyz.nuark.mods.electromana.utils.SupplierUtils;
import javax.annotation.Nullable;
import java.util.function.Supplier;
public class StructureType implements IForgeRegistryEntry<StructureType> {
private final BlockPos inStructPos;
private final ResourceLocation name;
private final Supplier<BlockArray> structureSupplier;
public StructureType(ResourceLocation name, BlockPos inStructPos, Supplier<BlockArray> structureSupplier) {
this.name = name;
this.inStructPos = inStructPos;
this.structureSupplier = SupplierUtils.memoizeLock(structureSupplier);
}
public BlockArray getStructure() {
return this.structureSupplier.get();
}
public ITextComponent getDisplayName() {
return new TranslationTextComponent(String.format("structure.%s.%s.name", name.getNamespace(), name.getPath()));
}
public boolean check(World world, BlockPos pos) throws BrokenStructureException {
return structureSupplier.get().check(pos, inStructPos, world);
}
@Override
public final StructureType setRegistryName(ResourceLocation name) {
return this;
}
@Nullable
@Override
public ResourceLocation getRegistryName() {
return this.name;
}
@Override
public Class<StructureType> getRegistryType() {
return StructureType.class;
}
}

View file

@ -0,0 +1,32 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;
import vazkii.botania.api.mana.IManaPool;
public abstract class BaseManaAltarTile extends TileEntity implements ITickableTileEntity, IMultiblockTile, INamedContainerProvider {
public BaseManaAltarTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
protected IManaPool getUpperManaPool() {
if (getWorld() == null) {
return null;
}
BlockPos upperBlock = getPos().up();
BlockState bs = getWorld().getBlockState(upperBlock);
if (bs.hasTileEntity()) {
TileEntity te = getWorld().getTileEntity(upperBlock);
if (te instanceof IManaPool) {
return (IManaPool) te;
}
}
return null;
}
}

View file

@ -0,0 +1,69 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;
import vazkii.botania.api.mana.IManaPool;
public abstract class BaseManaTransformerTile extends TileEntity implements ITickableTileEntity, INamedContainerProvider {
public enum Slots {
FUEL(0);
int id;
Slots(int number) {
id = number;
}
public int getId() {
return id;
}
}
public BaseManaTransformerTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
protected IManaPool getUpperManaPool() {
if (getWorld() == null) {
return null;
}
BlockPos upperBlock = getPos().up();
BlockState bs = getWorld().getBlockState(upperBlock);
if (bs.hasTileEntity()) {
TileEntity te = getWorld().getTileEntity(upperBlock);
if (te instanceof IManaPool) {
return (IManaPool) te;
}
}
return null;
}
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
return new SUpdateTileEntityPacket(pos, 0, getUpdateTag());
}
@Override
public CompoundNBT getUpdateTag() {
return write(new CompoundNBT());
}
@Override
public void handleUpdateTag(BlockState stateIn, CompoundNBT tag) {
read(stateIn, tag);
}
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
read(this.getBlockState(), pkt.getNbtCompound());
}
}

View file

@ -0,0 +1,153 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import vazkii.botania.api.mana.IManaReceiver;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaStructures;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.capabilities.ManaAltarEnergyStorage;
import xyz.nuark.mods.electromana.structure.StructureType;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// m'kay
// 1 hour for full pool = 3600 seconds
// Full pool = 2000000 points of mana
//
// Each second adds 555 mana to the pool (if presented) -> a little more than 1 hour to fill a full pool
public class ExquisiteManaAltarTile extends BaseManaAltarTile {
protected boolean hasMultiblock = false;
protected int ticksFormed = 0;
protected StructureType _structure;
public ManaAltarEnergyStorage energyStorage;
private LazyOptional<ManaAltarEnergyStorage> energy;
public ExquisiteManaAltarTile() {
super(ElectroManaTiles.EXQUISITE_MANA_ALTAR_TILE.get());
_structure = this.getRequiredStructureType();
this.energyStorage = new ManaAltarEnergyStorage(this, 0);
this.energy = LazyOptional.of(() -> this.energyStorage);
}
@Override
public void tick() {
if (!this.hasMultiblock) {
return;
}
ticksFormed += 1;
IManaReceiver mr = this.getUpperManaPool();
if (mr == null || mr.isFull() || (ticksFormed % 20) != 0) {
return;
}
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
ManaAltarEnergyStorage mts = (ManaAltarEnergyStorage) energyStorage;
int mxe = 1_000_000;
boolean canExtractEnergy = mts.consumeEnergy(mxe, true) == mxe;
if (canExtractEnergy) {
mts.consumeEnergy(mxe, false);
mr.receiveMana(555); // Y 555? See heading of class
}
});
}
public boolean validateMultiblock() throws BrokenStructureException {
if (getWorld().isRemote()) {
return this.hasMultiblock;
}
if (this.getRequiredStructureType() == null) {
resetMultiblockState();
return false;
}
boolean prevFound = this.hasMultiblock;
boolean found = _structure.check(getWorld(), getPos());
if (prevFound != found) {
ElectroMana.getLOGGER().info(
"Structure match updated: " + this.getClass().getName() + " at " + this.getPos() +
" (" + this.hasMultiblock + " -> " + found + ")"
);
this.hasMultiblock = found;
this.markForUpdate();
}
return this.hasMultiblock;
}
private void resetMultiblockState() {
ticksFormed = 0;
if (this.hasMultiblock) {
this.hasMultiblock = false;
this.markForUpdate();
}
}
@Nullable
@Override
public StructureType getRequiredStructureType() {
return ElectroManaStructures.EXQUISITE_MANA_ALTAR_STRUCTURE;
}
public void markForUpdate() {
if (getWorld() != null) {
BlockState thisState = this.getBlockState();
getWorld().notifyBlockUpdate(getPos(), thisState, thisState, 3);
}
markDirty();
}
@Override
public void read(BlockState stateIn, CompoundNBT compound) {
super.read(stateIn, compound);
energy.ifPresent(h -> h.deserializeNBT(compound.getCompound("energy")));
this.hasMultiblock = compound.getBoolean("hasMultiblock");
}
@Override
public CompoundNBT write(CompoundNBT compound) {
energy.ifPresent(h -> compound.put("energy", h.serializeNBT()));
compound.putBoolean("hasMultiblock", this.hasMultiblock);
return super.write(compound);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, final @Nullable Direction side) {
if (cap == CapabilityEnergy.ENERGY)
return energy.cast();
return super.getCapability(cap, side);
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Exquisite Mana Altar");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return null;
}
public boolean hasMultiblock() {
return hasMultiblock;
}
}

View file

@ -0,0 +1,155 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import vazkii.botania.api.mana.IManaReceiver;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaStructures;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.capabilities.ManaAltarEnergyStorage;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerStorage;
import xyz.nuark.mods.electromana.setup.Config;
import xyz.nuark.mods.electromana.structure.StructureType;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// m'kay
// 3 hours for full pool = 10800 seconds
// Full pool = 2000000 points of mana
//
// Each second adds 185 mana to the pool (if presented) -> a little more than 3 hours to fill a full pool
public class GreaterManaAltarTile extends BaseManaAltarTile {
protected boolean hasMultiblock = false;
protected int ticksFormed = 0;
protected StructureType _structure;
public ManaAltarEnergyStorage energyStorage;
private LazyOptional<ManaAltarEnergyStorage> energy;
public GreaterManaAltarTile() {
super(ElectroManaTiles.GREATER_MANA_ALTAR_TILE.get());
_structure = this.getRequiredStructureType();
this.energyStorage = new ManaAltarEnergyStorage(this, 0);
this.energy = LazyOptional.of(() -> this.energyStorage);
}
@Override
public void tick() {
if (!this.hasMultiblock) {
return;
}
ticksFormed += 1;
IManaReceiver mr = this.getUpperManaPool();
if (mr == null || mr.isFull() || (ticksFormed % 20) != 0) {
return;
}
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
ManaAltarEnergyStorage mts = (ManaAltarEnergyStorage) energyStorage;
int mxe = 1_000_000;
boolean canExtractEnergy = mts.consumeEnergy(mxe, true) == mxe;
if (canExtractEnergy) {
mts.consumeEnergy(mxe, false);
mr.receiveMana(185); // Y 185? See heading of class
}
});
}
public boolean validateMultiblock() throws BrokenStructureException {
if (getWorld().isRemote()) {
return this.hasMultiblock;
}
if (this.getRequiredStructureType() == null) {
resetMultiblockState();
return false;
}
boolean prevFound = this.hasMultiblock;
boolean found = _structure.check(getWorld(), getPos());
if (prevFound != found) {
ElectroMana.getLOGGER().info(
"Structure match updated: " + this.getClass().getName() + " at " + this.getPos() +
" (" + this.hasMultiblock + " -> " + found + ")"
);
this.hasMultiblock = found;
this.markForUpdate();
}
return this.hasMultiblock;
}
private void resetMultiblockState() {
ticksFormed = 0;
if (this.hasMultiblock) {
this.hasMultiblock = false;
this.markForUpdate();
}
}
@Nullable
@Override
public StructureType getRequiredStructureType() {
return ElectroManaStructures.GREATER_MANA_ALTAR_STRUCTURE;
}
public void markForUpdate() {
if (getWorld() != null) {
BlockState thisState = this.getBlockState();
getWorld().notifyBlockUpdate(getPos(), thisState, thisState, 3);
}
markDirty();
}
@Override
public void read(BlockState stateIn, CompoundNBT compound) {
super.read(stateIn, compound);
energy.ifPresent(h -> h.deserializeNBT(compound.getCompound("energy")));
this.hasMultiblock = compound.getBoolean("hasMultiblock");
}
@Override
public CompoundNBT write(CompoundNBT compound) {
energy.ifPresent(h -> compound.put("energy", h.serializeNBT()));
compound.putBoolean("hasMultiblock", this.hasMultiblock);
return super.write(compound);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, final @Nullable Direction side) {
if (cap == CapabilityEnergy.ENERGY)
return energy.cast();
return super.getCapability(cap, side);
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Greater Mana Altar");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return null;
}
public boolean hasMultiblock() {
return hasMultiblock;
}
}

View file

@ -0,0 +1,10 @@
package xyz.nuark.mods.electromana.tile;
import xyz.nuark.mods.electromana.structure.StructureType;
import javax.annotation.Nullable;
public interface IMultiblockTile {
@Nullable
public StructureType getRequiredStructureType();
}

View file

@ -0,0 +1,163 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.items.CapabilityItemHandler;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import xyz.nuark.mods.electromana.ElectroMana;
import xyz.nuark.mods.electromana.ElectroManaStructures;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.capabilities.ManaAltarEnergyStorage;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerStorage;
import xyz.nuark.mods.electromana.setup.Config;
import xyz.nuark.mods.electromana.structure.StructureType;
import xyz.nuark.mods.electromana.utils.BrokenStructureException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// m'kay
// 6 hours for full pool = 21600 seconds
// Full pool = 2000000 points of mana
//
// Each second adds 111 mana to the pool (if presented) -> a little more than 5 hours to fill a full pool
public class LesserManaAltarTile extends BaseManaAltarTile {
protected boolean hasMultiblock = false;
protected int ticksFormed = 0;
protected StructureType _structure;
public ManaAltarEnergyStorage energyStorage;
private LazyOptional<ManaAltarEnergyStorage> energy;
public LesserManaAltarTile() {
super(ElectroManaTiles.LESSER_MANA_ALTAR_TILE.get());
_structure = this.getRequiredStructureType();
this.energyStorage = new ManaAltarEnergyStorage(this, 0);
this.energy = LazyOptional.of(() -> this.energyStorage);
}
@Override
public void tick() {
if (!this.hasMultiblock) {
return;
}
ticksFormed += 1;
IManaReceiver mr = this.getUpperManaPool();
if (mr == null || mr.isFull() || (ticksFormed % 20) != 0) {
return;
}
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
ManaAltarEnergyStorage mts = (ManaAltarEnergyStorage) energyStorage;
int mxe = 1_000_000;
boolean canExtractEnergy = mts.consumeEnergy(mxe, true) == mxe;
if (canExtractEnergy) {
mts.consumeEnergy(mxe, false);
mr.receiveMana(111); // Y 111? See heading of class
}
});
}
public boolean validateMultiblock() throws BrokenStructureException {
if (getWorld().isRemote()) {
return this.hasMultiblock;
}
if (this.getRequiredStructureType() == null) {
resetMultiblockState();
return false;
}
boolean prevFound = this.hasMultiblock;
boolean found = _structure.check(getWorld(), getPos());
if (prevFound != found) {
ElectroMana.getLOGGER().info(
"Structure match updated: " + this.getClass().getName() + " at " + this.getPos() +
" (" + this.hasMultiblock + " -> " + found + ")"
);
this.hasMultiblock = found;
this.markForUpdate();
}
return this.hasMultiblock;
}
private void resetMultiblockState() {
ticksFormed = 0;
if (this.hasMultiblock) {
this.hasMultiblock = false;
this.markForUpdate();
}
}
@Nullable
@Override
public StructureType getRequiredStructureType() {
return ElectroManaStructures.LESSER_MANA_ALTAR_STRUCTURE;
}
public void markForUpdate() {
if (getWorld() != null) {
BlockState thisState = this.getBlockState();
getWorld().notifyBlockUpdate(getPos(), thisState, thisState, 3);
}
markDirty();
}
@Override
public void read(BlockState stateIn, CompoundNBT compound) {
super.read(stateIn, compound);
energy.ifPresent(h -> h.deserializeNBT(compound.getCompound("energy")));
this.hasMultiblock = compound.getBoolean("hasMultiblock");
}
@Override
public CompoundNBT write(CompoundNBT compound) {
energy.ifPresent(h -> compound.put("energy", h.serializeNBT()));
compound.putBoolean("hasMultiblock", this.hasMultiblock);
return super.write(compound);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, final @Nullable Direction side) {
if (cap == CapabilityEnergy.ENERGY)
return energy.cast();
return super.getCapability(cap, side);
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Lesser Mana Altar");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return null;
}
public boolean hasMultiblock() {
return hasMultiblock;
}
}

View file

@ -0,0 +1,232 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.IIntArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerItemHandler;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerStorage;
import xyz.nuark.mods.electromana.container.ManaTransformerContainer;
import xyz.nuark.mods.electromana.setup.Config;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ManaTransformerMK2Tile extends BaseManaTransformerTile {
private int counter = 0;
private int maxBurn = 0;
public ManaTransformerStorage energyStorage;
private LazyOptional<ManaTransformerStorage> energy;
private LazyOptional<ItemStackHandler> inventory = LazyOptional.of(() -> new ManaTransformerItemHandler(this));
public final IIntArray manaTransformerData = new IIntArray() {
@Override
public int get(int index) {
switch (index) {
case 0:
return ManaTransformerMK2Tile.this.energyStorage.getEnergyStored() / 32;
case 1:
return ManaTransformerMK2Tile.this.energyStorage.getMaxEnergyStored() / 32;
case 2:
return ManaTransformerMK2Tile.this.counter;
case 3:
return ManaTransformerMK2Tile.this.maxBurn;
case 4:
return ManaTransformerMK2Tile.this.getUpperManaPool() != null ? ManaTransformerMK2Tile.this.getUpperManaPool().getCurrentMana() : 0;
case 5:
return ManaTransformerMK2Tile.this.getUpperManaPool() != null ? ManaTransformerMK2Tile.this.getUpperManaPool().tileEntity().getUpdateTag().getInt("manaCap") : 0;
default:
throw new IllegalArgumentException("Invalid index: " + index);
}
}
@Override
public void set(int index, int value) {
throw new IllegalStateException("Cannot set values through IIntArray");
}
@Override
public int size() {
return 6;
}
};
public ManaTransformerMK2Tile() {
super(ElectroManaTiles.MANA_TRANSFORMER_TILE_MK2.get());
this.energyStorage = new ManaTransformerStorage(this, 0, Config.CHARGE_MAX_POWER_MK2.get());
this.energy = LazyOptional.of(() -> this.energyStorage);
}
@Nullable
@Override
public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) {
assert world != null;
return new ManaTransformerContainer(this, this.manaTransformerData, i, playerInventory, this.inventory.orElse(new ItemStackHandler(1)));
}
@Override
public void tick() {
if (getWorld() == null) {
return;
}
tryPushMana();
inventory.ifPresent(handler -> {
tryBurn();
});
}
private void tryBurn() {
if (world == null)
return;
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
boolean canInsertEnergy = energyStorage.receiveEnergy(625, true) > 0;
if (counter > 0 && canInsertEnergy) {
burn(energyStorage);
} else if (canInsertEnergy) {
if (initBurn()) {
burn(energyStorage);
}
}
});
}
private void tryPushMana() {
if (world == null)
return;
IManaReceiver mr = getUpperManaPool();
if (mr == null) {
return;
}
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
ManaTransformerStorage mts = (ManaTransformerStorage) energyStorage;
int mxe = Config.POWER_USAGE_MK2.get();
boolean canExtractEnergy = mts.consumeEnergy(mxe, true) == mxe;
if (canExtractEnergy && !mr.isFull()) {
mts.consumeEnergy(mxe, false);
mr.receiveMana(1);
}
});
}
private void burn(IEnergyStorage energyStorage) {
energyStorage.receiveEnergy(5000, false);
counter--;
if (counter == 0) {
maxBurn = 0;
initBurn();
}
}
private boolean initBurn() {
ItemStackHandler handler = inventory.orElseThrow(RuntimeException::new);
ItemStack stack = handler.getStackInSlot(Slots.FUEL.id);
int burnTime = ForgeHooks.getBurnTime(stack);
if (burnTime > 0) {
Item fuelStack = handler.getStackInSlot(Slots.FUEL.id).getItem();
handler.extractItem(0, 1, false);
if (fuelStack instanceof BucketItem && fuelStack != Items.BUCKET)
handler.insertItem(0, new ItemStack(Items.BUCKET, 1), false);
markDirty();
counter = (int) Math.floor(burnTime) / 50;
maxBurn = counter;
return true;
}
return false;
}
@Override
public void read(BlockState stateIn, CompoundNBT compound) {
super.read(stateIn, compound);
inventory.ifPresent(h -> h.deserializeNBT(compound.getCompound("inv")));
energy.ifPresent(h -> h.deserializeNBT(compound.getCompound("energy")));
counter = compound.getInt("counter");
maxBurn = compound.getInt("maxburn");
}
@Override
public CompoundNBT write(CompoundNBT compound) {
inventory.ifPresent(h -> compound.put("inv", h.serializeNBT()));
energy.ifPresent(h -> compound.put("energy", h.serializeNBT()));
compound.putInt("counter", counter);
compound.putInt("maxburn", maxBurn);
return super.write(compound);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, final @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return inventory.cast();
if (cap == CapabilityEnergy.ENERGY)
return energy.cast();
return super.getCapability(cap, side);
}
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
return new SUpdateTileEntityPacket(pos, 0, getUpdateTag());
}
@Override
public CompoundNBT getUpdateTag() {
return write(new CompoundNBT());
}
@Override
public void handleUpdateTag(BlockState stateIn, CompoundNBT tag) {
read(stateIn, tag);
}
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
read(this.getBlockState(), pkt.getNbtCompound());
}
@Override
public void remove() {
energy.invalidate();
inventory.invalidate();
super.remove();
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Mana Transformer Tile MK2");
}
}

View file

@ -0,0 +1,232 @@
package xyz.nuark.mods.electromana.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.IIntArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import xyz.nuark.mods.electromana.ElectroManaTiles;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerItemHandler;
import xyz.nuark.mods.electromana.capabilities.ManaTransformerStorage;
import xyz.nuark.mods.electromana.container.ManaTransformerContainer;
import xyz.nuark.mods.electromana.setup.Config;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ManaTransformerTile extends BaseManaTransformerTile {
private int counter = 0;
private int maxBurn = 0;
public ManaTransformerStorage energyStorage;
private LazyOptional<ManaTransformerStorage> energy;
private LazyOptional<ItemStackHandler> inventory = LazyOptional.of(() -> new ManaTransformerItemHandler(this));
public final IIntArray manaTransformerData = new IIntArray() {
@Override
public int get(int index) {
switch (index) {
case 0:
return ManaTransformerTile.this.energyStorage.getEnergyStored() / 32;
case 1:
return ManaTransformerTile.this.energyStorage.getMaxEnergyStored() / 32;
case 2:
return ManaTransformerTile.this.counter;
case 3:
return ManaTransformerTile.this.maxBurn;
case 4:
return ManaTransformerTile.this.getUpperManaPool() != null ? ManaTransformerTile.this.getUpperManaPool().getCurrentMana() : 0;
case 5:
return ManaTransformerTile.this.getUpperManaPool() != null ? ManaTransformerTile.this.getUpperManaPool().tileEntity().getUpdateTag().getInt("manaCap") : 0;
default:
throw new IllegalArgumentException("Invalid index: " + index);
}
}
@Override
public void set(int index, int value) {
throw new IllegalStateException("Cannot set values through IIntArray");
}
@Override
public int size() {
return 6;
}
};
public ManaTransformerTile() {
super(ElectroManaTiles.MANA_TRANSFORMER_TILE.get());
this.energyStorage = new ManaTransformerStorage(this, 0, Config.CHARGE_MAX_POWER.get());
this.energy = LazyOptional.of(() -> this.energyStorage);
}
@Nullable
@Override
public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) {
assert world != null;
return new ManaTransformerContainer(this, this.manaTransformerData, i, playerInventory, this.inventory.orElse(new ItemStackHandler(1)));
}
@Override
public void tick() {
if (getWorld() == null) {
return;
}
tryPushMana();
inventory.ifPresent(handler -> {
tryBurn();
});
}
private void tryBurn() {
if (world == null)
return;
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
boolean canInsertEnergy = energyStorage.receiveEnergy(625, true) > 0;
if (counter > 0 && canInsertEnergy) {
burn(energyStorage);
} else if (canInsertEnergy) {
if (initBurn()) {
burn(energyStorage);
}
}
});
}
private void tryPushMana() {
if (world == null)
return;
IManaReceiver mr = getUpperManaPool();
if (mr == null) {
return;
}
this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
ManaTransformerStorage mts = (ManaTransformerStorage) energyStorage;
int mxe = Config.POWER_USAGE.get();
boolean canExtractEnergy = mts.consumeEnergy(mxe, true) == mxe;
if (canExtractEnergy && !mr.isFull()) {
mts.consumeEnergy(mxe, false);
mr.receiveMana(Config.GENERATION_MAX_MANA.get());
}
});
}
private void burn(IEnergyStorage energyStorage) {
energyStorage.receiveEnergy(625, false);
counter--;
if (counter == 0) {
maxBurn = 0;
initBurn();
}
}
private boolean initBurn() {
ItemStackHandler handler = inventory.orElseThrow(RuntimeException::new);
ItemStack stack = handler.getStackInSlot(Slots.FUEL.id);
int burnTime = ForgeHooks.getBurnTime(stack);
if (burnTime > 0) {
Item fuelStack = handler.getStackInSlot(Slots.FUEL.id).getItem();
handler.extractItem(0, 1, false);
if (fuelStack instanceof BucketItem && fuelStack != Items.BUCKET)
handler.insertItem(0, new ItemStack(Items.BUCKET, 1), false);
markDirty();
counter = (int) Math.floor(burnTime) / 50;
maxBurn = counter;
return true;
}
return false;
}
@Override
public void read(BlockState stateIn, CompoundNBT compound) {
super.read(stateIn, compound);
inventory.ifPresent(h -> h.deserializeNBT(compound.getCompound("inv")));
energy.ifPresent(h -> h.deserializeNBT(compound.getCompound("energy")));
counter = compound.getInt("counter");
maxBurn = compound.getInt("maxburn");
}
@Override
public CompoundNBT write(CompoundNBT compound) {
inventory.ifPresent(h -> compound.put("inv", h.serializeNBT()));
energy.ifPresent(h -> compound.put("energy", h.serializeNBT()));
compound.putInt("counter", counter);
compound.putInt("maxburn", maxBurn);
return super.write(compound);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, final @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return inventory.cast();
if (cap == CapabilityEnergy.ENERGY)
return energy.cast();
return super.getCapability(cap, side);
}
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
return new SUpdateTileEntityPacket(pos, 0, getUpdateTag());
}
@Override
public CompoundNBT getUpdateTag() {
return write(new CompoundNBT());
}
@Override
public void handleUpdateTag(BlockState stateIn, CompoundNBT tag) {
read(stateIn, tag);
}
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
read(this.getBlockState(), pkt.getNbtCompound());
}
@Override
public void remove() {
energy.invalidate();
inventory.invalidate();
super.remove();
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Mana Transformer Tile");
}
}

View file

@ -0,0 +1,7 @@
package xyz.nuark.mods.electromana.utils;
public class BrokenStructureException extends Exception {
public BrokenStructureException(String message) {
super(message);
}
}

View file

@ -0,0 +1,7 @@
package xyz.nuark.mods.electromana.utils;
public class MathUtils {
public static boolean inRect(int x, int y, int x0, int y0, int x1, int y1) {
return x0 <= x && x <= x1 && y0 <= y && y <= y1;
}
}

View file

@ -0,0 +1,16 @@
package xyz.nuark.mods.electromana.utils;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class NetworkUtils {
public static ActionResultType activateBlock(World world, BlockPos pos, PlayerEntity player, Runnable action) {
if (!world.isRemote) {
action.run();
}
return ActionResultType.SUCCESS;
}
}

View file

@ -0,0 +1,21 @@
package xyz.nuark.mods.electromana.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class StringHelpers {
public static String withSuffix(int count) {
if (count < 1000) return "" + count;
int exp = (int) (Math.log(count) / Math.log(1000));
return String.format("%.1f%c",
count / Math.pow(1000, exp),
"kMGTPE".charAt(exp - 1));
}
private static final BigDecimal TWENTY = new BigDecimal(20);
public static String ticksInSeconds(int ticks) {
BigDecimal value = new BigDecimal(ticks);
value = value.divide(TWENTY, 1, RoundingMode.HALF_UP);
return value.toString();
}
}

View file

@ -0,0 +1,24 @@
package xyz.nuark.mods.electromana.utils;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
public class SupplierUtils {
public static <T> Supplier<T> memoizeLock(Supplier<T> delegate) {
AtomicReference<T> value = new AtomicReference<>();
return () -> {
T val = value.get();
if (val == null) {
synchronized(value) {
val = value.get();
if (val == null) {
val = Objects.requireNonNull(delegate.get());
value.set(val);
}
}
}
return val;
};
}
}

View file

@ -0,0 +1,65 @@
# 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="[36,)" #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="All rights reserved"
# 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="electromana" #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="ElectroMana" #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="ElectroMana.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="nuark" #optional
# The description text for the mod (multi line!) (#mandatory)
description='''
Use a lot of FE to passively generate Botania Mana
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.ElectroMana]] #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="[36,)" #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.ElectroMana]]
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.16.5,1.17)"
ordering="NONE"
side="BOTH"
[[dependencies.ElectroMana]]
modId="botania"
mandatory = true
versionRange = "[r1.16.4-414,)"
ordering = "NONE"
side="BOTH"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Some files were not shown because too many files have changed in this diff Show more