diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f811f6a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Disable autocrlf on generated files, they always generate with LF +# Add any extra files or paths here to make git stop saying they +# are changed when only line endings change. +src/generated/**/.cache/cache text eol=lf +src/generated/**/*.json text eol=lf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e6d72d6 --- /dev/null +++ b/Makefile @@ -0,0 +1,96 @@ +# @file Makefile +# @author Stefan Wilhelm (wile) +# @license MIT +# +# GNU Make makefile based build relay. +# Note for reviewers/clones: This file is a auxiliary script for my setup. +# It's not needed to build the mod. +# +MOD_JAR_PREFIX=engineersdecor- +MOD_JAR=$(filter-out %-sources.jar,$(wildcard build/libs/${MOD_JAR_PREFIX}*.jar)) + +ifeq ($(OS),Windows_NT) +GRADLE=gradlew.bat --no-daemon +GRADLE_STOP=gradlew.bat --stop +DJS=djs +else +GRADLE=./gradlew --no-daemon +GRADLE_STOP=./gradlew --stop +DJS=djs +endif +TASK=$(DJS) ../meta/lib/tasks.js + +wildcardr=$(foreach d,$(wildcard $1*),$(call wildcardr,$d/,$2) $(filter $(subst *,%,$2),$d)) + +# +# Targets +# +.PHONY: default mod data init clean clean-all mrproper all run install sanitize dist-check dist start-server assets + +default: mod + +all: clean clean-all mod | install + +mod: + @echo "[1.16] Building mod using gradle ..." + @$(GRADLE) build $(GRADLE_OPTS) + +assets: + @echo "[1.16] Running asset generators ..." + @$(TASK) assets + +data: + @echo "[1.16] Running data generators ..." + @$(TASK) datagen + +clean: + @echo "[1.16] Cleaning ..." + @rm -rf src/generated + @rm -rf mcmodsrepo + @rm -f build/libs/* + @$(GRADLE) clean + +clean-all: + @echo "[1.16] Cleaning using gradle ..." + @rm -rf mcmodsrepo + @rm -f dist/* + @rm -rf run/logs/ + @rm -rf run/crash-reports/ + @$(GRADLE) clean + +mrproper: clean-all + @rm -f meta/*.* + @rm -rf run/ + @rm -rf out/ + @rm -f .project + @rm -f .classpath + +init: + @echo "[1.16] Initialising eclipse workspace using gradle ..." + @$(GRADLE) eclipse + +sanitize: + @echo "[1.16] Running sanitising tasks ..." + @$(TASK) sanitize + @$(TASK) sync-languages + @$(TASK) version-check + @$(TASK) update-json + @git status -s . + +install: $(MOD_JAR) | + @$(TASK) install + +start-server: install + @$(TASK) start-server + +dist-check: + @echo "[1.16] Running dist checks ..." + @$(TASK) dist-check + +dist-files: clean-all init mod + @echo "[1.16] Distribution files ..." + @mkdir -p dist + @cp build/libs/$(MOD_JAR_PREFIX)* dist/ + @$(TASK) dist + +dist: sanitize dist-check dist-files diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1424b24 --- /dev/null +++ b/build.gradle @@ -0,0 +1,120 @@ +// @file build.gradle +// Engineer's decor mod gradle build relay (mc1.15.1) +import net.minecraftforge.gradle.common.task.SignJar +buildscript { + repositories { + maven { url = 'https://files.minecraftforge.net/maven' } + jcenter() + mavenCentral() + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + } +} +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'eclipse' +apply plugin: 'maven-publish' +sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' +//---------------------------------------------------------------------------------------------------------------------- +version = "${version_engineersdecor}" +group = "wile.engineersdecor" +archivesBaseName = "engineersdecor-${version_minecraft}" + +repositories { + maven { name = "Progwml6 maven"; url = "https://dvs1.progwml6.com/files/maven/" } // JEI files + maven { name = "ModMaven"; url = "https://modmaven.k-4u.nl" } // JEI files, fallback +} + +minecraft { + mappings channel: 'snapshot', version: "${version_fml_mappings}" + // accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg') + runs { + client { + workingDirectory project.file('run') + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + mods { + engineersdecor { + source sourceSets.main + } + } + } + server { + workingDirectory project.file('run') + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + mods { + engineersdecor { + source sourceSets.main + } + } + } + data { + workingDirectory project.file('run') + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + args '--mod', 'engineersdecor', '--all', '--output', file('src/generated/resources/') + mods { + engineersdecor { + source sourceSets.main + } + } + } + } +} + +dependencies { + minecraft "net.minecraftforge:forge:${version_forge_minecraft}" + compileOnly fg.deobf("mezz.jei:jei-${version_jei}:api") + runtimeOnly fg.deobf("mezz.jei:jei-${version_jei}") +} + +processResources { + outputs.upToDateWhen { false } // thx to @tterrag for this hint + doLast { file("${sourceSets.main.output.resourcesDir}/.gitversion-engineersdecor").text = 'git log "-1" "--format=%h"'.execute().in.text.trim() } +} + +jar { + manifest { + attributes([ + "Specification-Title": "engineersdecor", + "Specification-Vendor": "wilechaote", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version_engineersdecor}", + "Implementation-Vendor" :"wilechaote", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} + +def reobfFile = file("$buildDir/reobfJar/output.jar") +def reobfArtifact = artifacts.add('default', reobfFile) { type 'jar'; builtBy 'reobfJar' } + +def signing = { -> + def sp = new Properties() + sp.keystore_file = project.keystore_file + sp.keystore_alias = project.keystore_alias + sp.keystore_pass = project.keystore_pass + sp.keystore_keypass = project.keystore_keypass + sp.fingerprint_sha1 = project.fingerprint_sha1 + if(file("signing.properties").exists()) file("signing.properties").withInputStream { sp.load(it) } + return sp +}(); +task signJar(type: SignJar, dependsOn: jar) { + onlyIf { signing.hasProperty("keystore_file") } + if(signing.hasProperty("keystore_file")) { + keyStore = signing.getProperty("keystore_file") + alias = signing.getProperty("keystore_alias") + storePass = signing.getProperty("keystore_pass") + keyPass = signing.getProperty("keystore_keypass") + inputFile = jar.archivePath + outputFile = jar.archivePath + } +} +build.dependsOn signJar + +publishing { + publications { mavenJava(MavenPublication) { artifact reobfArtifact } } + repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..394a45a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +# @file gradle.properties +org.gradle.daemon=false +org.gradle.jvmargs=-Xmx8G +version_minecraft=1.16.1 +version_forge_minecraft=1.16.1-32.0.97 +version_fml_mappings=20200514-1.16 +version_jei=1.16.1:7.0.0.6 +version_engineersdecor=1.1.1-b6 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7a3265e Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1d5b29f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/meta/update.json b/meta/update.json index dcaf3c3..b2571aa 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.16.1": { + "1.1.1-b5": "[M] Transmuted the \"Treated Wood Crafting Table\" to a \"Metal Crafting Table\" to de-duplicate the new Immersive Engineering \"Engineer's Crafting Table\".\n[F] Fixed metal pole culling (issue #109, thx Alsett).", "1.1.1-b4": "[F] Fixed Fluid Barrel tooltip text duplicate.\n[F] Fixed IE hard-dependency opt-out.\n[M] Side Table model and shape refined.\n[A] Dense Grit Dirt added.\n[M] Wood textures slightly darker, obsolete textures removed.", "1.1.1-b3": "[A] Ceiling Edge Light added.\n[A] Iron Bulb Light added.\n[A] Iron Hatch added.\n[A] Fluid Barrel added.\n[M] Gas Concrete texture made slightly darker.", "1.1.1-b2": "[M] Nerfed Solar Panel output default config value from 45RF/t to 40RF/t.\n[F] Fixed conditional IE tag dependency of alternative/standalone recipes.", @@ -8,7 +9,7 @@ "1.1.1-a1": "[A] Initial port." }, "promos": { - "1.16.1-recommended": "1.1.1-b4", - "1.16.1-latest": "1.1.1-b4" + "1.16.1-recommended": "1.1.1-b5", + "1.16.1-latest": "1.1.1-b5" } } \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..90d3254 --- /dev/null +++ b/readme.md @@ -0,0 +1,42 @@ + +## Engineer's Decor (MC1.15.1) + +Mod sources for Minecraft version 1.15.1. + +- Description, credits, and features: Please see the readme in the repository root. + +- Compiled mod distribution channel is curseforge: https://www.curseforge.com/minecraft/mc-mods/engineers-decor/files. + +---- + +## Version history + + ~ v1.1.1-b6 [F] Iron Hatch rendering fixed (issue #113, ty KrAzYGEEK32). + + - v1.1.1-b5 [M] Transmuted the "Treated Wood Crafting Table" to a "Metal Crafting Table" + to de-duplicate the new Immersive Engineering "Engineer's Crafting Table". + [F] Fixed metal pole culling (issue #109, thx Alsett). + + - v1.1.1-b4 [F] Fixed Fluid Barrel tooltip text duplicate. + [F] Fixed IE hard-dependency opt-out. + [M] Side Table model and shape refined. + [A] Dense Grit Dirt added. + [M] Wood textures slightly darker, obsolete textures removed. + + - v1.1.1-b3 [A] Ceiling Edge Light added. + [A] Iron Bulb Light added. + [A] Iron Hatch added. + [A] Fluid Barrel added. + [M] Gas Concrete texture made slightly darker. + + - v1.1.1-b2 [M] Nerfed Solar Panel output default config value from 45RF/t to 40RF/t. + [F] Fixed conditional IE tag dependency of alternative/standalone recipes. + + - v1.1.1-b1 [A] JEI integration ported. + [M] Logical server side config moved from COMMON to SERVER (world/serverconfig). + [F] Labeled Crate recipe condition for missing Immersive Engineering fixed. + [F] Mouse scrolling works for Labeled Crate and TW Crafting Table. + + - v1.1.1-a1 [A] Initial port. + +---- diff --git a/src/main/java/wile/engineersdecor/ModConfig.java b/src/main/java/wile/engineersdecor/ModConfig.java new file mode 100644 index 0000000..8af5e65 --- /dev/null +++ b/src/main/java/wile/engineersdecor/ModConfig.java @@ -0,0 +1,707 @@ +/* + * @file ModConfig.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2018 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Main class for module settings. Handles reading and + * saving the config file. + */ +package wile.engineersdecor; + +import wile.engineersdecor.blocks.*; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraftforge.common.ForgeConfigSpec; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.Logger; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.HashSet; + +public class ModConfig +{ + //-------------------------------------------------------------------------------------------------------------------- + private static final Logger LOGGER = ModEngineersDecor.logger(); + private static final String MODID = ModEngineersDecor.MODID; + public static final CommonConfig COMMON; + public static final ServerConfig SERVER; + public static final ClientConfig CLIENT; + public static final ForgeConfigSpec COMMON_CONFIG_SPEC; + public static final ForgeConfigSpec SERVER_CONFIG_SPEC; + public static final ForgeConfigSpec CLIENT_CONFIG_SPEC; + + static { + final Pair common_ = (new ForgeConfigSpec.Builder()).configure(CommonConfig::new); + COMMON_CONFIG_SPEC = common_.getRight(); + COMMON = common_.getLeft(); + final Pair server_ = (new ForgeConfigSpec.Builder()).configure(ServerConfig::new); + SERVER_CONFIG_SPEC = server_.getRight(); + SERVER = server_.getLeft(); + final Pair client_ = (new ForgeConfigSpec.Builder()).configure(ClientConfig::new); + CLIENT_CONFIG_SPEC = client_.getRight(); + CLIENT = client_.getLeft(); + } + + //-------------------------------------------------------------------------------------------------------------------- + + public static class ClientConfig + { + public final ForgeConfigSpec.BooleanValue without_tooltips; + public final ForgeConfigSpec.BooleanValue without_ters; + + ClientConfig(ForgeConfigSpec.Builder builder) + { + builder.comment("Settings not loaded on servers.") + .push("client"); + // --- OPTOUTS ------------------------------------------------------------ + { + builder.comment("Opt-out settings") + .push("optout"); + without_tooltips = builder + .translation(MODID + ".config.without_tooltips") + .comment("Disable CTRL-SHIFT item tooltip display.") + .define("without_tooltips", false); + without_ters = builder + .translation(MODID + ".config.without_ters") + .comment("Disable all TERs (tile entity renderers).") + .define("without_ters", false); + } + builder.pop(); + } + } + + //-------------------------------------------------------------------------------------------------------------------- + + public static class CommonConfig + { + CommonConfig(ForgeConfigSpec.Builder builder) + { + } + } + + //-------------------------------------------------------------------------------------------------------------------- + + public static class ServerConfig + { + // Optout + public final ForgeConfigSpec.ConfigValue pattern_excludes; + public final ForgeConfigSpec.ConfigValue pattern_includes; + public final ForgeConfigSpec.BooleanValue without_clinker_bricks; + public final ForgeConfigSpec.BooleanValue without_slag_bricks; + public final ForgeConfigSpec.BooleanValue without_rebar_concrete; + public final ForgeConfigSpec.BooleanValue without_gas_concrete; + public final ForgeConfigSpec.BooleanValue without_walls; + public final ForgeConfigSpec.BooleanValue without_stairs; + public final ForgeConfigSpec.BooleanValue without_ie_concrete_wall; + public final ForgeConfigSpec.BooleanValue without_panzer_glass; + public final ForgeConfigSpec.BooleanValue without_ladders; + public final ForgeConfigSpec.BooleanValue without_treated_wood_furniture; + public final ForgeConfigSpec.BooleanValue without_metal_furniture; + public final ForgeConfigSpec.BooleanValue without_windows; + public final ForgeConfigSpec.BooleanValue without_light_sources; + public final ForgeConfigSpec.BooleanValue without_slabs; + public final ForgeConfigSpec.BooleanValue without_halfslabs; + public final ForgeConfigSpec.BooleanValue without_poles; + public final ForgeConfigSpec.BooleanValue without_hsupports; + public final ForgeConfigSpec.BooleanValue without_sign_plates; + public final ForgeConfigSpec.BooleanValue without_floor_grating; + public final ForgeConfigSpec.BooleanValue without_crafting_table; + public final ForgeConfigSpec.BooleanValue without_lab_furnace; + public final ForgeConfigSpec.BooleanValue without_electrical_furnace; + public final ForgeConfigSpec.BooleanValue without_valves; + public final ForgeConfigSpec.BooleanValue without_passive_fluid_accumulator; + public final ForgeConfigSpec.BooleanValue without_waste_incinerator; + public final ForgeConfigSpec.BooleanValue without_factory_dropper; + public final ForgeConfigSpec.BooleanValue without_factory_hopper; + public final ForgeConfigSpec.BooleanValue without_factory_placer; + public final ForgeConfigSpec.BooleanValue without_block_breaker; + public final ForgeConfigSpec.BooleanValue without_solar_panel; + public final ForgeConfigSpec.BooleanValue without_fluid_funnel; + public final ForgeConfigSpec.BooleanValue without_mineral_smelter; + public final ForgeConfigSpec.BooleanValue without_milking_machine; + public final ForgeConfigSpec.BooleanValue without_tree_cutter; + public final ForgeConfigSpec.BooleanValue without_labeled_crate; + public final ForgeConfigSpec.BooleanValue without_fences; + public final ForgeConfigSpec.BooleanValue without_chair_sitting; + public final ForgeConfigSpec.BooleanValue without_mob_chair_sitting; + public final ForgeConfigSpec.BooleanValue without_ladder_speed_boost; + public final ForgeConfigSpec.BooleanValue without_crafting_table_history; + public final ForgeConfigSpec.BooleanValue without_direct_slab_pickup; + public final ForgeConfigSpec.BooleanValue with_creative_mode_device_drops; + // Misc + public final ForgeConfigSpec.BooleanValue with_experimental; + public final ForgeConfigSpec.BooleanValue without_recipes; + // Tweaks + public final ForgeConfigSpec.IntValue furnace_smelting_speed_percent; + public final ForgeConfigSpec.IntValue furnace_fuel_efficiency_percent; + public final ForgeConfigSpec.IntValue furnace_boost_energy_consumption; + public final ForgeConfigSpec.IntValue e_furnace_speed_percent; + public final ForgeConfigSpec.IntValue e_furnace_power_consumption; + public final ForgeConfigSpec.IntValue small_solar_panel_peak_production; + public final ForgeConfigSpec.BooleanValue e_furnace_automatic_pulling; + public final ForgeConfigSpec.DoubleValue chair_mob_sitting_probability_percent; + public final ForgeConfigSpec.DoubleValue chair_mob_standup_probability_percent; + public final ForgeConfigSpec.BooleanValue without_crafting_mouse_scrolling; + public final ForgeConfigSpec.IntValue pipevalve_max_flowrate; + public final ForgeConfigSpec.IntValue pipevalve_redstone_gain; + public final ForgeConfigSpec.IntValue block_breaker_power_consumption; + public final ForgeConfigSpec.IntValue block_breaker_reluctance; + public final ForgeConfigSpec.IntValue block_breaker_min_breaking_time; + public final ForgeConfigSpec.BooleanValue block_breaker_requires_power; + public final ForgeConfigSpec.IntValue tree_cuttter_energy_consumption; + public final ForgeConfigSpec.IntValue tree_cuttter_cutting_time_needed; + public final ForgeConfigSpec.BooleanValue tree_cuttter_requires_power; + public final ForgeConfigSpec.IntValue milking_machine_energy_consumption; + public final ForgeConfigSpec.IntValue milking_machine_milking_delay; + + ServerConfig(ForgeConfigSpec.Builder builder) + { + builder.comment("Settings affecting the logical server side.") + .push("server"); + // --- OPTOUTS ------------------------------------------------------------ + { + builder.comment("Opt-out settings") + .push("optout"); + pattern_excludes = builder + .translation(MODID + ".config.pattern_excludes") + .comment("Opt-out any block by its registry name ('*' wildcard matching, " + + "comma separated list, whitespaces ignored. You must match the whole name, " + + "means maybe add '*' also at the begin and end. Example: '*wood*,*steel*' " + + "excludes everything that has 'wood' or 'steel' in the registry name. " + + "The matching result is also traced in the log file. ") + .define("pattern_excludes", ""); + pattern_includes = builder + .translation(MODID + ".config.pattern_includes") + .comment("Prevent blocks from being opt'ed by registry name ('*' wildcard matching, " + + "comma separated list, whitespaces ignored. Evaluated before all other opt-out checks. " + + "You must match the whole name, means maybe add '*' also at the begin and end. Example: " + + "'*wood*,*steel*' includes everything that has 'wood' or 'steel' in the registry name." + + "The matching result is also traced in the log file.") + .define("pattern_includes", ""); + without_clinker_bricks = builder + .translation(MODID + ".config.without_clinker_bricks") + .comment("Disable clinker bricks and derived blocks.") + .define("without_clinker_bricks", false); + without_slag_bricks = builder + .translation(MODID + ".config.without_slag_bricks") + .comment("Disable slag bricks and derived blocks.") + .define("without_slag_bricks", false); + without_rebar_concrete = builder + .translation(MODID + ".config.without_rebar_concrete") + .comment("Disable rebar concrete and derived blocks.") + .define("without_rebar_concrete", false); + without_gas_concrete = builder + .translation(MODID + ".config.without_gas_concrete") + .comment("Disable gas concrete and derived blocks.") + .define("without_gas_concrete", false); + without_walls = builder + .translation(MODID + ".config.without_walls") + .comment("Disable all mod wall blocks.") + .define("without_walls", false); + without_stairs = builder + .translation(MODID + ".config.without_stairs") + .comment("Disable all mod stairs blocks.") + .define("without_stairs", false); + without_ie_concrete_wall = builder + .translation(MODID + ".config.without_ie_concrete_wall") + .comment("Disable IE concrete wall.") + .define("without_ie_concrete_wall", false); + without_panzer_glass = builder + .translation(MODID + ".config.without_panzer_glass") + .comment("Disable panzer glass and derived blocks.") + .define("without_panzer_glass", false); + without_crafting_table = builder + .translation(MODID + ".config.without_crafting_table") + .comment("Disable crafting table.") + .define("without_crafting_table", false); + without_lab_furnace = builder + .translation(MODID + ".config.without_lab_furnace") + .comment("Disable small lab furnace.") + .define("without_lab_furnace", false); + without_electrical_furnace = builder + .translation(MODID + ".config.without_electrical_furnace") + .comment("Disable small electrical pass-through furnace.") + .define("without_electrical_furnace", false); + without_treated_wood_furniture = builder + .translation(MODID + ".config.without_treated_wood_furniture") + .comment("Disable treated wood table, stool, windowsill, etc.") + .define("without_treated_wood_furniture", false); + without_metal_furniture = builder + .translation(MODID + ".config.without_metal_furniture") + .comment("Disable metal tables, etc.") + .define("without_metal_furniture", false); + without_windows = builder + .translation(MODID + ".config.without_windows") + .comment("Disable treated wood window, etc.") + .define("without_windows", false); + without_light_sources = builder + .translation(MODID + ".config.without_light_sources") + .comment("Disable light sources") + .define("without_light_sources", false); + without_ladders = builder + .translation(MODID + ".config.without_ladders") + .comment("Disable ladders") + .define("without_ladders", false); + without_chair_sitting = builder + .translation(MODID + ".config.without_chair_sitting") + .comment("Disable possibility to sit on stools and chairs.") + .define("without_chair_sitting", false); + without_mob_chair_sitting = builder + .translation(MODID + ".config.without_mob_chair_sitting") + .comment("Disable that mobs will sit on chairs and stools.") + .define("without_mob_chair_sitting", false); + without_ladder_speed_boost = builder + .translation(MODID + ".config.without_ladder_speed_boost") + .comment("Disable the speed boost of ladders in this mod.") + .define("without_ladder_speed_boost", false); + without_crafting_table_history = builder + .translation(MODID + ".config.without_crafting_table_history") + .comment("Disable history refabrication feature of the crafting table.") + .define("without_crafting_table_history", false); + without_valves = builder + .translation(MODID + ".config.without_valves") + .comment("Disable check valve, and redstone controlled valves.") + .define("without_valves", false); + without_passive_fluid_accumulator = builder + .translation(MODID + ".config.without_passive_fluid_accumulator") + .comment("Disable the passive fluid accumulator.") + .define("without_passive_fluid_accumulator", false); + without_waste_incinerator = builder + .translation(MODID + ".config.without_waste_incinerator") + .comment("Disable item disposal/trash/void incinerator device.") + .define("without_waste_incinerator", false); + without_sign_plates = builder + .translation(MODID + ".config.without_sign_plates") + .comment("Disable decorative sign plates (caution, hazards, etc).") + .define("without_sign_plates", false); + without_floor_grating = builder + .translation(MODID + ".config.without_floor_grating") + .comment("Disable floor gratings.") + .define("without_floor_grating", false); + without_factory_dropper = builder + .translation(MODID + ".config.without_factory_dropper") + .comment("Disable the factory dropper.") + .define("without_factory_dropper", false); + without_factory_hopper = builder + .translation(MODID + ".config.without_factory_hopper") + .comment("Disable the factory hopper.") + .define("without_factory_hopper", false); + without_factory_placer = builder + .translation(MODID + ".config.without_factory_placer") + .comment("Disable the factory placer.") + .define("without_factory_placer", false); + without_block_breaker = builder + .translation(MODID + ".config.without_block_breaker") + .comment("Disable the small block breaker.") + .define("without_block_breaker", false); + without_solar_panel = builder + .translation(MODID + ".config.without_solar_panel") + .comment("Disable the small solar panel.") + .define("without_solar_panel", false); + without_fluid_funnel = builder + .translation(MODID + ".config.without_fluid_funnel") + .comment("Disable the small fluid collection funnel.") + .define("without_fluid_funnel", false); + without_mineral_smelter = builder + .translation(MODID + ".config.without_mineral_smelter") + .comment("Disable the small mineral smelter.") + .define("without_mineral_smelter", false); + without_milking_machine = builder + .translation(MODID + ".config.without_milking_machine") + .comment("Disable the small milking machine.") + .define("without_milking_machine", false); + without_tree_cutter = builder + .translation(MODID + ".config.without_tree_cutter") + .comment("Disable the small tree cutter.") + .define("without_tree_cutter", false); + without_labeled_crate = builder + .translation(MODID + ".config.without_labeled_crate") + .comment("Disable labeled crate.") + .define("without_labeled_crate", false); + without_slabs = builder + .translation(MODID + ".config.without_slabs") + .comment("Disable horizontal half-block slab.") + .define("without_slabs", false); + without_halfslabs = builder + .translation(MODID + ".config.without_halfslabs") + .comment("Disable stackable 1/8 block slices.") + .define("without_halfslabs", false); + without_poles = builder + .translation(MODID + ".config.without_poles") + .comment("Disable poles of any material.") + .define("without_poles", false); + without_hsupports = builder + .translation(MODID + ".config.without_hsupports") + .comment("Disable horizontal supports like the double-T support.") + .define("without_hsupports", false); + without_recipes = builder + .translation(MODID + ".config.without_recipes") + .comment("Disable all internal recipes, allowing to use alternative pack recipes.") + .define("without_recipes", false); + without_fences = builder + .translation(MODID + ".config.without_fences") + .comment("Disable all fences and fence gates.") + .define("without_fences", false); + builder.pop(); + } + // --- MISC --------------------------------------------------------------- + { + builder.comment("Miscellaneous settings") + .push("miscellaneous"); + with_experimental = builder + .translation(MODID + ".config.with_experimental") + .comment("Enables experimental features. Use at own risk.") + .define("with_experimental", false); + without_direct_slab_pickup = builder + .translation(MODID + ".config.without_direct_slab_pickup") + .comment("Disable directly picking up layers from slabs and slab " + + " slices by left clicking while looking up/down.") + .define("without_direct_slab_pickup", false); + with_creative_mode_device_drops = builder + .translation(MODID + ".config.with_creative_mode_device_drops") + .comment("Enable that devices are dropped as item also in creative mode, allowing " + + " to relocate them with contents and settings.") + .define("with_creative_mode_device_drops", false); + builder.pop(); + } + // --- TWEAKS ------------------------------------------------------------- + { + builder.comment("Tweaks") + .push("tweaks"); + furnace_smelting_speed_percent = builder + .translation(MODID + ".config.furnace_smelting_speed_percent") + .comment("Defines, in percent, how fast the lab furnace smelts compared to " + + "a vanilla furnace. 100% means vanilla furnace speed, 150% means the " + + "lab furnace is faster. The value can be changed on-the-fly for tuning.") + .defineInRange("furnace_smelting_speed_percent", 130, 50, 800); + furnace_fuel_efficiency_percent = builder + .translation(MODID + ".config.furnace_fuel_efficiency_percent") + .comment("Defines, in percent, how fuel efficient the lab furnace is, compared " + + "to a vanilla furnace. 100% means vanilla furnace consumiton, 200% means " + + "the lab furnace needs about half the fuel of a vanilla furnace, " + + "The value can be changed on-the-fly for tuning.") + .defineInRange("furnace_fuel_efficiency_percent", 100, 50, 400); + furnace_boost_energy_consumption = builder + .translation(MODID + ".config.furnace_boost_energy_consumption") + .comment("Defines the energy consumption (per tick) for speeding up the smelting process. " + + "If IE is installed, an external heater has to be inserted into an auxiliary slot " + + "of the lab furnace. The power source needs to be able to provide at least 4 times " + + "this consumption (fixed threshold value). The value can be changed on-the-fly for tuning. " + + "The default value corresponds to the IE heater consumption.") + .defineInRange("furnace_boost_energy_consumption", 24, 2, 1024); + chair_mob_sitting_probability_percent = builder + .translation(MODID + ".config.chair_mob_sitting_probability_percent") + .comment("Defines, in percent, how high the probability is that a mob sits on a chair " + + "when colliding with it. Can be changed on-the-fly for tuning.") + .defineInRange("chair_mob_sitting_probability_percent", 10.0, 0.0, 80.0); + chair_mob_standup_probability_percent = builder + .translation(MODID + ".config.chair_mob_standup_probability_percent") + .comment("Defines, in percent, probable it is that a mob leaves a chair when sitting " + + "on it. The 'dice is rolled' about every 20 ticks. There is also a minimum " + + "Sitting time of about 3s. The config value can be changed on-the-fly for tuning.") + .defineInRange("chair_mob_standup_probability_percent", 1.0, 1e-3, 10.0); + without_crafting_mouse_scrolling = builder + .translation(MODID + ".config.without_crafting_mouse_scrolling") + .comment("Disables increasing/decreasing the crafting grid items by scrolling over the crafting result slot.") + .define("without_crafting_mouse_scrolling", false); + pipevalve_max_flowrate = builder + .translation(MODID + ".config.pipevalve_max_flowrate") + .comment("Defines how many millibuckets can be transferred (per tick) through the valves. " + + "That is technically the 'storage size' specified for blocks that want to fill " + + "fluids into the valve (the valve has no container and forward that to the output " + + "block), The value can be changed on-the-fly for tuning. ") + .defineInRange("pipevalve_max_flowrate", 1000, 1, 32000); + pipevalve_redstone_gain = builder + .translation(MODID + ".config.pipevalve_redstone_gain") + .comment("Defines how many millibuckets per redstone signal strength can be transferred per tick " + + "through the analog redstone controlled valves. Note: power 0 is always off, power 15 is always " + + "the max flow rate. Between power 1 and 14 this scaler will result in a flow = 'redstone slope' * 'current redstone power'. " + + "The value can be changed on-the-fly for tuning. ") + .defineInRange("pipevalve_redstone_gain", 20, 1, 32000); + e_furnace_speed_percent = builder + .translation(MODID + ".config.e_furnace_speed_percent") + .comment("Defines, in percent, how fast the electrical furnace smelts compared to " + + "a vanilla furnace. 100% means vanilla furnace speed, 150% means the " + + "electrical furnace is faster. The value can be changed on-the-fly for tuning.") + .defineInRange("e_furnace_speed_percent", EdElectricalFurnace.ElectricalFurnaceTileEntity.DEFAULT_SPEED_PERCENT, 50, 800); + e_furnace_power_consumption = builder + .translation(MODID + ".config.e_furnace_power_consumption") + .comment("Defines how much RF per tick the the electrical furnace consumed (average) for smelting. " + + "The feeders transferring items from/to adjacent have this consumption/8 for each stack transaction. " + + "The default value is only slightly higher than a furnace with an IE external heater (and no burning fuel inside)." + + "The config value can be changed on-the-fly for tuning.") + .defineInRange("e_furnace_power_consumption", EdElectricalFurnace.ElectricalFurnaceTileEntity.DEFAULT_ENERGY_CONSUMPTION, 8, 4096); + e_furnace_automatic_pulling = builder + .translation(MODID + ".config.e_furnace_automatic_pulling") + .comment("Defines if the electrical furnace automatically pulls items from an inventory at the input side." + + "The config value can be changed on-the-fly for tuning.") + .define("e_furnace_automatic_pulling", false); + small_solar_panel_peak_production = builder + .translation(MODID + ".config.small_solar_panel_peak_production") + .comment("Defines the peak power production (at noon) of the Small Solar Panel. " + + "Note that the agerage power is much less, as no power is produced at all during the night, " + + "and the power curve is nonlinear rising/falling during the day. Bad weather conditions also " + + "decrease the production. The config value can be changed on-the-fly for tuning.") + .defineInRange("small_solar_panel_peak_production", EdSolarPanel.SolarPanelTileEntity.DEFAULT_PEAK_POWER, 2, 4096); + block_breaker_power_consumption = builder + .translation(MODID + ".config.block_breaker_power_consumption") + .comment("Defines how much RF power the Small Block Breaker requires to magnificently increase the processing speed. " + + "The config value can be changed on-the-fly for tuning.") + .defineInRange("block_breaker_power_consumption", EdBreaker.BreakerTileEntity.DEFAULT_BOOST_ENERGY, 4, 1024); + block_breaker_reluctance = builder + .translation(MODID + ".config.block_breaker_reluctance") + .comment("Defines how much time the Small Block Breaker needs per block hardness, " + + "means: 'reluctance' * hardness + min_time, you change the 'reluctance' here." + + "The unit is ticks/hardness. " + "The config value can be changed on-the-fly for tuning.") + .defineInRange("block_breaker_reluctance", EdBreaker.BreakerTileEntity.DEFAULT_BREAKING_RELUCTANCE, 5, 50); + block_breaker_min_breaking_time = builder + .translation(MODID + ".config.block_breaker_min_breaking_time") + .comment("Defines how much time the Small Block Breaker needs at least, better said it's an offset: " + + "'reluctance' * hardness + min_time, you change the 'min_time' here, value " + + "in ticks." + "The config value can be changed on-the-fly for tuning.") + .defineInRange("block_breaker_min_breaking_time", EdBreaker.BreakerTileEntity.DEFAULT_MIN_BREAKING_TIME, 10, 100); + block_breaker_requires_power = builder + .translation(MODID + ".config.block_breaker_requires_power") + .comment("Defines if the Small Block Breaker does not work without RF power.") + .define("block_breaker_requires_power", false); + tree_cuttter_energy_consumption = builder + .translation(MODID + ".config.tree_cuttter_energy_consumption") + .comment("Defines how much RF power the Small Tree Cutter requires to magnificently increase the processing speed. " + + "The config value can be changed on-the-fly for tuning.") + .defineInRange("tree_cuttter_energy_consumption", EdTreeCutter.TreeCutterTileEntity.DEFAULT_BOOST_ENERGY, 4, 1024); + tree_cuttter_cutting_time_needed = builder + .translation(MODID + ".config.tree_cuttter_cutting_time_needed") + .comment("Defines how much time the Small Tree Cutter needs to cut a tree without RF power. " + + "The value is in seconds. With energy it is 6 times faster. " + + "The config value can be changed on-the-fly for tuning.") + .defineInRange("tree_cuttter_cutting_time_needed", EdTreeCutter.TreeCutterTileEntity.DEFAULT_CUTTING_TIME_NEEDED, 10, 240); + tree_cuttter_requires_power = builder + .translation(MODID + ".config.tree_cuttter_requires_power") + .comment("Defines if the Small Tree Cutter does not work without RF power.") + .define("tree_cuttter_requires_power", false); + milking_machine_energy_consumption = builder + .translation(MODID + ".config.milking_machine_energy_consumption") + .comment("Defines how much time the Small Milking Machine needs work. " + + "Note this is a permanent standby power, not only when the device does something. " + + "Use zero to disable energy dependency and energy handling of the machine. " + + "The config value can be changed on-the-fly for tuning.") + .defineInRange("milking_machine_energy_consumption", EdMilker.MilkerTileEntity.DEFAULT_ENERGY_CONSUMPTION, 0, 1024); + milking_machine_milking_delay = builder + .translation(MODID + ".config.milking_machine_milking_delay") + .comment("Defines (for each individual cow) the minimum time between milking." ) + .defineInRange("milking_machine_milking_delay", EdMilker.MilkerTileEntity.DEFAULT_MILKING_DELAY_PER_COW, 1000, 24000); + builder.pop(); + } + } + } + + + //-------------------------------------------------------------------------------------------------------------------- + // Optout checks + //-------------------------------------------------------------------------------------------------------------------- + + public static final boolean isOptedOut(final @Nullable Block block) + { return isOptedOut(block.asItem()); } + + public static final boolean isOptedOut(final @Nullable Item item) + { return (item!=null) && optouts_.contains(item.getRegistryName().getPath()); } + + public static boolean withExperimental() + { return with_experimental_features_; } + + public static boolean withoutRecipes() + { return without_recipes_; } + + //-------------------------------------------------------------------------------------------------------------------- + // Cache + //-------------------------------------------------------------------------------------------------------------------- + + private static final CompoundNBT server_config_ = new CompoundNBT(); + private static HashSet optouts_ = new HashSet<>(); + private static boolean with_experimental_features_ = false; + private static boolean without_recipes_ = false; + public static boolean without_crafting_table = false; + public static boolean immersiveengineering_installed = false; + public static boolean without_direct_slab_pickup = false; + public static boolean with_creative_mode_device_drops = false; + + public static final CompoundNBT getServerConfig() // config that may be synchronized from server to client via net pkg. + { return server_config_; } + + private static final void updateOptouts() + { + final ArrayList includes_ = new ArrayList(); + final ArrayList excludes_ = new ArrayList(); + { + String inc = SERVER.pattern_includes.get().toLowerCase().replaceAll(MODID+":", "").replaceAll("[^*_,a-z0-9]", ""); + if(SERVER.pattern_includes.get() != inc) SERVER.pattern_includes.set(inc); + if(!inc.isEmpty()) LOGGER.info("Config pattern includes: '" + inc + "'"); + String[] incl = inc.split(","); + includes_.clear(); + for(int i=0; i< incl.length; ++i) { + incl[i] = incl[i].replaceAll("[*]", ".*?"); + if(!incl[i].isEmpty()) includes_.add(incl[i]); + } + } + { + String exc = SERVER.pattern_excludes.get().toLowerCase().replaceAll(MODID+":", "").replaceAll("[^*_,a-z0-9]", ""); + if(!exc.isEmpty()) LOGGER.info("Config pattern excludes: '" + exc + "'"); + String[] excl = exc.split(","); + excludes_.clear(); + for(int i=0; i< excl.length; ++i) { + excl[i] = excl[i].replaceAll("[*]", ".*?"); + if(!excl[i].isEmpty()) excludes_.add(excl[i]); + } + } + { + boolean with_log_details = false; + HashSet optouts = new HashSet<>(); + ModContent.getRegisteredItems().stream().filter((Item item) -> { + if(item == null) return true; + if(SERVER == null) return false; + return false; + }).forEach( + e -> optouts.add(e.getRegistryName().getPath()) + ); + ModContent.getRegisteredBlocks().stream().filter((Block block) -> { + if(block==null) return true; + if(block==ModContent.SIGN_MODLOGO) return true; + if(COMMON==null) return false; + try { + if(!SERVER.with_experimental.get()) { + if(block instanceof Auxiliaries.IExperimentalFeature) return true; + if(ModContent.isExperimentalBlock(block)) return true; + } + // Hard IE dependent blocks + if(!immersiveengineering_installed) { + if((block instanceof IDecorBlock) && ((((IDecorBlock)block).config() & DecorBlock.CFG_HARD_IE_DEPENDENT)!=0)) return true; + if((block instanceof DecorBlock.Normal) && ((((DecorBlock.Normal)block).config & DecorBlock.CFG_HARD_IE_DEPENDENT)!=0)) return true; + if((block instanceof StandardBlocks.BaseBlock) && ((((StandardBlocks.BaseBlock)block).config & DecorBlock.CFG_HARD_IE_DEPENDENT)!=0)) return true; + } + // Force-include/exclude pattern matching + final String rn = block.getRegistryName().getPath(); + try { + for(String e : includes_) { + if(rn.matches(e)) { + if(with_log_details) LOGGER.info("Optout force include: "+rn); + return false; + } + } + for(String e : excludes_) { + if(rn.matches(e)) { + if(with_log_details) LOGGER.info("Optout force exclude: "+rn); + return true; + } + } + } catch(Throwable ex) { + LOGGER.error("optout include pattern failed, disabling."); + includes_.clear(); + excludes_.clear(); + } + // Early non-opt out type based evaluation + if(block instanceof EdCraftingTable.CraftingTableBlock) return SERVER.without_crafting_table.get(); + if(block instanceof EdElectricalFurnace.ElectricalFurnaceBlock) return SERVER.without_electrical_furnace.get(); + if((block instanceof EdFurnace.FurnaceBlock)&&(!(block instanceof EdElectricalFurnace.ElectricalFurnaceBlock))) return SERVER.without_lab_furnace.get(); + if(block instanceof EdFluidAccumulator.FluidAccumulatorBlock) return SERVER.without_passive_fluid_accumulator.get(); + if(block instanceof EdWasteIncinerator.WasteIncineratorBlock) return SERVER.without_waste_incinerator.get(); + if(block instanceof EdDropper.DropperBlock) return SERVER.without_factory_dropper.get(); + if(block instanceof EdPlacer.PlacerBlock) return SERVER.without_factory_placer.get(); + if(block instanceof EdBreaker.BreakerBlock) return SERVER.without_block_breaker.get(); + if(block instanceof EdSlabSliceBlock) return SERVER.without_halfslabs.get(); + if(block instanceof EdLadderBlock) return SERVER.without_ladders.get(); + if(block instanceof EdWindowBlock) return SERVER.without_windows.get(); + if(block instanceof EdPipeValve.PipeValveBlock) return SERVER.without_valves.get(); + if(block instanceof EdHorizontalSupportBlock) return SERVER.without_hsupports.get(); + if(block instanceof EdFloorGratingBlock) return SERVER.without_floor_grating.get(); + if(block instanceof EdHopper.HopperBlock) return SERVER.without_factory_hopper.get(); + if(block instanceof EdFluidFunnel.FluidFunnelBlock) return SERVER.without_fluid_funnel.get(); + if(block instanceof EdSolarPanel.SolarPanelBlock) return SERVER.without_solar_panel.get(); + if(block instanceof EdMineralSmelter.MineralSmelterBlock) return SERVER.without_mineral_smelter.get(); + if(block instanceof EdMilker.MilkerBlock) return SERVER.without_milking_machine.get(); + if(block instanceof EdTreeCutter.TreeCutterBlock) return SERVER.without_tree_cutter.get(); + if(block instanceof EdLabeledCrate.LabeledCrateBlock) return SERVER.without_labeled_crate.get(); + // Type based evaluation where later filters may match, too + if(SERVER.without_slabs.get()&&(block instanceof EdSlabBlock)) return true; + if(SERVER.without_stairs.get()&&(block instanceof EdStairsBlock)) return true; + if(SERVER.without_walls.get()&&(block instanceof EdWallBlock)) return true; + if(SERVER.without_poles.get()&&(block instanceof EdStraightPoleBlock)) return true; + // String matching based evaluation + if(SERVER.without_clinker_bricks.get()&&(rn.startsWith("clinker_brick_"))) return true; + if(SERVER.without_slag_bricks.get()&&rn.startsWith("slag_brick_")) return true; + if(SERVER.without_rebar_concrete.get()&&rn.startsWith("rebar_concrete")) return true; + if(SERVER.without_gas_concrete.get()&&rn.startsWith("gas_concrete")) return true; + if(SERVER.without_ie_concrete_wall.get()&&rn.startsWith("ie_concrete_wall")) return true; + if(SERVER.without_panzer_glass.get()&&rn.startsWith("panzerglass_")) return true; + if(SERVER.without_light_sources.get()&&rn.endsWith("_light")) return true; + if(SERVER.without_sign_plates.get()&&rn.startsWith("sign_")) return true; + if(SERVER.without_treated_wood_furniture.get()) { + if(block instanceof EdChair.ChairBlock) return true; + if(rn.equals("treated_wood_table")) return true; + if(rn.equals("treated_wood_stool")) return true; + if(rn.equals("treated_wood_windowsill")) return true; + if(rn.equals("treated_wood_broad_windowsill")) return true; + if(rn.equals("treated_wood_side_table")) return true; + } + if(SERVER.without_metal_furniture.get()) { + if(rn.equals("steel_table")) return true; + } + if(SERVER.without_fences.get()) { + if(block instanceof EdFenceBlock) return true; + if(block instanceof EdDoubleGateBlock) return true; + } + } catch(Exception ex) { + LOGGER.error("Exception evaluating the optout config: '"+ex.getMessage()+"'"); + } + return false; + }).forEach( + e -> optouts.add(e.getRegistryName().getPath()) + ); + optouts_ = optouts; + } + } + + public static final void apply() + { + with_experimental_features_ = SERVER.with_experimental.get(); + if(with_experimental_features_) LOGGER.info("Config: EXPERIMENTAL FEATURES ENABLED."); + immersiveengineering_installed = Auxiliaries.isModLoaded("immersiveengineering"); + updateOptouts(); + without_crafting_table = isOptedOut(ModContent.CRAFTING_TABLE); + without_recipes_ = SERVER.without_recipes.get(); + without_direct_slab_pickup = SERVER.without_direct_slab_pickup.get(); + // ----------------------------------------------------------------------------------------------------------------- + EdFurnace.FurnaceTileEntity.on_config(SERVER.furnace_smelting_speed_percent.get(), SERVER.furnace_fuel_efficiency_percent.get(), SERVER.furnace_boost_energy_consumption.get()); + EdChair.on_config(SERVER.without_chair_sitting.get(), SERVER.without_mob_chair_sitting.get(), SERVER.chair_mob_sitting_probability_percent.get(), SERVER.chair_mob_standup_probability_percent.get()); + EdLadderBlock.on_config(SERVER.without_ladder_speed_boost.get()); + EdCraftingTable.on_config(SERVER.without_crafting_table_history.get(), false, SERVER.without_crafting_mouse_scrolling.get()); + EdPipeValve.on_config(SERVER.pipevalve_max_flowrate.get(), SERVER.pipevalve_redstone_gain.get()); + EdElectricalFurnace.ElectricalFurnaceTileEntity.on_config(SERVER.e_furnace_speed_percent.get(), SERVER.e_furnace_power_consumption.get(), SERVER.e_furnace_automatic_pulling.get()); + EdSolarPanel.SolarPanelTileEntity.on_config(SERVER.small_solar_panel_peak_production.get()); + EdBreaker.BreakerTileEntity.on_config(SERVER.block_breaker_power_consumption.get(), SERVER.block_breaker_reluctance.get(), SERVER.block_breaker_min_breaking_time.get(), SERVER.block_breaker_requires_power.get()); + EdTreeCutter.TreeCutterTileEntity.on_config(SERVER.tree_cuttter_energy_consumption.get(), SERVER.tree_cuttter_cutting_time_needed.get(), SERVER.tree_cuttter_requires_power.get()); + EdMilker.MilkerTileEntity.on_config(SERVER.milking_machine_energy_consumption.get(), SERVER.milking_machine_milking_delay.get()); + EdSlabBlock.on_config(!SERVER.without_direct_slab_pickup.get()); + EdSlabSliceBlock.on_config(!SERVER.without_direct_slab_pickup.get()); + // currently no file config planned + EdLabeledCrate.on_config(false); + EdFluidFunnel.on_config(with_experimental_features_); // @todo: double check for abuse as pump first + EdDropper.on_config(with_experimental_features_); // @todo: double check handler cross-mod-compat first + EdFluidBarrel.on_config(12000, 1000); + // ----------------------------------------------------------------------------------------------------------------- + { + // Check if the config is already synchronized or has to be synchronised. + server_config_.putBoolean("tree_cuttter_requires_power", SERVER.tree_cuttter_requires_power.get()); + server_config_.putBoolean("block_breaker_requires_power", SERVER.block_breaker_requires_power.get()); + { + String s = String.join(",", optouts_); + server_config_.putString("optout", s); + if(!s.isEmpty()) LOGGER.info("Opt-outs:" + s); + } + } + } +} diff --git a/src/main/java/wile/engineersdecor/ModContent.java b/src/main/java/wile/engineersdecor/ModContent.java new file mode 100644 index 0000000..b033fb3 --- /dev/null +++ b/src/main/java/wile/engineersdecor/ModContent.java @@ -0,0 +1,1159 @@ +/* + * @file ModContent.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2018 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Definition and initialisation of blocks of this + * module, along with their tile entities if applicable. + * + * Note: Straight forward definition of different blocks/entities + * to make recipes, models and texture definitions easier. + */ +package wile.engineersdecor; + +import wile.engineersdecor.blocks.*; +import wile.engineersdecor.blocks.EdFurnace.FurnaceBlock; +import wile.engineersdecor.blocks.EdFurnace.FurnaceContainer; +import wile.engineersdecor.blocks.EdFurnace.FurnaceGui; +import wile.engineersdecor.blocks.EdFurnace.FurnaceTileEntity; +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks.IStandardBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.block.material.MaterialColor; +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.item.Item; +import net.minecraft.item.BlockItem; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.client.gui.ScreenManager; +import net.minecraftforge.common.ToolType; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import org.apache.commons.lang3.ArrayUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.Collections; +import javax.annotation.Nonnull; + + +@SuppressWarnings("unused") +public class ModContent +{ + //-------------------------------------------------------------------------------------------------------------------- + // Blocks + //-------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal CLINKER_BRICK_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_block")); + + public static final EdSlabBlock CLINKER_BRICK_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_slab")); + + public static final EdStairsBlock CLINKER_BRICK_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + CLINKER_BRICK_BLOCK.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_stairs")); + + public static final EdWallBlock CLINKER_BRICK_WALL = (EdWallBlock)(new EdWallBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_wall")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal CLINKER_BRICK_STAINED_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_stained_block")); + + public static final EdSlabBlock CLINKER_BRICK_STAINED_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_stained_slab")); + + public static final EdStairsBlock CLINKER_BRICK_STAINED_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + CLINKER_BRICK_BLOCK.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "clinker_brick_stained_stairs")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal SLAG_BRICK_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "slag_brick_block")); + + public static final EdSlabBlock SLAG_BRICK_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "slag_brick_slab")); + + public static final EdStairsBlock SLAG_BRICK_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + SLAG_BRICK_BLOCK.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "slag_brick_stairs")); + + public static final EdWallBlock SLAG_BRICK_WALL = (EdWallBlock)(new EdWallBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(3f, 50f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "slag_brick_wall")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal REBAR_CONCRETE_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete")); + + public static final EdSlabBlock REBAR_CONCRETE_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_slab")); + + public static final EdStairsBlock REBAR_CONCRETE_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + REBAR_CONCRETE_BLOCK.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_stairs")); + + public static final EdWallBlock REBAR_CONCRETE_WALL = (EdWallBlock)(new EdWallBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_wall")); + + public static final EdSlabSliceBlock HALFSLAB_REBARCONCRETE = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_rebar_concrete")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal GAS_CONCRETE_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1.5f, 10f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "gas_concrete")); + + public static final EdSlabBlock GAS_CONCRETE_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1.5f, 10f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "gas_concrete_slab")); + + public static final EdStairsBlock GAS_CONCRETE_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + REBAR_CONCRETE_BLOCK.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1.5f, 10f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "gas_concrete_stairs")); + + public static final EdWallBlock GAS_CONCRETE_WALL = (EdWallBlock)(new EdWallBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1.5f, 10f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "gas_concrete_wall")); + + public static final EdSlabSliceBlock HALFSLAB_GASCONCRETE = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1.5f, 10f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_gas_concrete")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.Normal REBAR_CONCRETE_TILE = (DecorBlock.Normal)(new DecorBlock.Normal( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_tile")); + + public static final EdSlabBlock REBAR_CONCRETE_TILE_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_tile_slab")); + + public static final EdStairsBlock REBAR_CONCRETE_TILE_STAIRS = (EdStairsBlock)(new EdStairsBlock( + DecorBlock.CFG_DEFAULT, + REBAR_CONCRETE_TILE.getDefaultState(), + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(5f, 2000f).sound(SoundType.STONE) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "rebar_concrete_tile_stairs")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdGlassBlock PANZERGLASS_BLOCK = (EdGlassBlock)(new EdGlassBlock( + DecorBlock.CFG_TRANSLUCENT, + Block.Properties.create(Material.GLASS, MaterialColor.AIR).hardnessAndResistance(0.7f, 2000f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "panzerglass_block")); + + public static final EdSlabBlock PANZERGLASS_SLAB = (EdSlabBlock)(new EdSlabBlock( + DecorBlock.CFG_TRANSLUCENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(0.7f, 2000f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "panzerglass_slab")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdGroundBlock DENSE_GRIT_SAND = (EdGroundBlock)(new EdGroundBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.EARTH, MaterialColor.DIRT).hardnessAndResistance(0.5f, 3f).sound(SoundType.GROUND).harvestTool(ToolType.SHOVEL) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dense_grit_sand_block")); + + public static final EdGroundBlock DENSE_GRIT_DIRT = (EdGroundBlock)(new EdGroundBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.EARTH, MaterialColor.DIRT).hardnessAndResistance(0.5f, 3f).sound(SoundType.GROUND).harvestTool(ToolType.SHOVEL) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dense_grit_dirt_block")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdLadderBlock METAL_RUNG_LADDER = (EdLadderBlock)(new EdLadderBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1.0f, 25f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "metal_rung_ladder")); + + public static final EdLadderBlock METAL_RUNG_STEPS = (EdLadderBlock)(new EdLadderBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1.0f, 25f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "metal_rung_steps")); + + public static final EdLadderBlock TREATED_WOOD_LADDER = (EdLadderBlock)(new EdLadderBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1.0f, 25f).sound(SoundType.WOOD).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_ladder")); + + public static final EdHatchBlock IRON_HATCH = (EdHatchBlock)(new EdHatchBlock( + DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 2000f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0.5,1,0, 15.5,3,14), + Auxiliaries.getPixeledAABB(0.5,1,0, 15.5,14.,2) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_hatch")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.WaterLoggable TREATED_WOOD_TABLE = (DecorBlock.WaterLoggable)(new DecorBlock.WaterLoggable( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(1,0,1, 15,15.9,15) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_table")); + + public static final EdChair.ChairBlock TREATED_WOOD_STOOL = (EdChair.ChairBlock)(new EdChair.ChairBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(4,7,4, 12,8.8,12), + Auxiliaries.getPixeledAABB(7,0,7, 9,7,9), + Auxiliaries.getPixeledAABB(4,0,7, 12,1,9), + Auxiliaries.getPixeledAABB(7,0,4, 9,1,12), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_stool")); + + public static final DecorBlock.WaterLoggable TREATED_WOOD_SIDE_TABLE = (DecorBlock.WaterLoggable)(new DecorBlock.WaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 2,15, 2, 14,16,14), + Auxiliaries.getPixeledAABB( 3,15, 1, 13,16, 2), + Auxiliaries.getPixeledAABB( 3,15,14, 13,16,15), + Auxiliaries.getPixeledAABB( 1,15, 3, 2,16,13), + Auxiliaries.getPixeledAABB(14,15, 3, 15,16,13), + Auxiliaries.getPixeledAABB( 3,14, 3, 13,15,13), + Auxiliaries.getPixeledAABB( 7, 3, 7, 9,12, 9), + Auxiliaries.getPixeledAABB( 2, 0, 7, 14, 1, 9), + Auxiliaries.getPixeledAABB( 7, 0, 2, 9, 1,14) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_side_table")); + + public static final DecorBlock.DirectedWaterLoggable TREATED_WOOD_WINDOWSILL = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_FACING_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_windowsill")); + + public static final DecorBlock.DirectedWaterLoggable TREATED_WOOD_BROAD_WINDOWSILL = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_FACING_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(0,14.5,4, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_broad_windowsill")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.DirectedWaterLoggable INSET_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(), + Auxiliaries.getPixeledAABB(5.2,5.2,0, 10.8,10.8,0.3) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_inset_light")); + + public static final DecorBlock.DirectedWaterLoggable FLOOR_EDGE_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(), + Auxiliaries.getPixeledAABB(5,0,0, 11,2,0.5) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_floor_edge_light")); + + public static final DecorBlock.DirectedWaterLoggable CEILING_EDGE_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 0,15.5,0, 16,16,2.0), + Auxiliaries.getPixeledAABB( 0,14.0,0, 16,16,0.5), + Auxiliaries.getPixeledAABB( 0,14.0,0, 1,16,2.0), + Auxiliaries.getPixeledAABB(15,14.0,0, 16,16,2.0), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_ceiling_edge_light")); + + public static final DecorBlock.DirectedWaterLoggable BULB_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(6.5,6.5,1, 9.5,9.5,4), + Auxiliaries.getPixeledAABB(6.0,6.0,0, 10.0,10.0,1.0) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_bulb_light")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.WaterLoggable STEEL_TABLE = (DecorBlock.WaterLoggable)(new DecorBlock.WaterLoggable( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_table")); + + public static final EdFloorGratingBlock STEEL_FLOOR_GRATING = (EdFloorGratingBlock)(new EdFloorGratingBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,14,0, 16,15.5,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_floor_grating")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdWindowBlock TREATED_WOOD_WINDOW = (EdWindowBlock)(new EdWindowBlock( + DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS).notSolid(), + Auxiliaries.getPixeledAABB(0,0,7, 16,16,9) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_window")); + + public static final EdWindowBlock STEEL_FRAMED_WINDOW = (EdWindowBlock)(new EdWindowBlock( + DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS).notSolid(), + Auxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_framed_window")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdStraightPoleBlock TREATED_WOOD_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole")); + + public static final EdStraightPoleBlock TREATED_WOOD_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_head")); + + public static final EdStraightPoleBlock TREATED_WOOD_POLE_SUPPORT = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_pole_support")); + + public static final EdStraightPoleBlock THIN_STEEL_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole")); + + public static final EdStraightPoleBlock THIN_STEEL_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thin_steel_pole_head")); + + public static final EdStraightPoleBlock THICK_STEEL_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole")); + + public static final EdStraightPoleBlock THICK_STEEL_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "thick_steel_pole_head")); + + public static final EdHorizontalSupportBlock STEEL_DOUBLE_T_SUPPORT = (EdHorizontalSupportBlock)(new EdHorizontalSupportBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(5,11,0, 11,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_double_t_support")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final DecorBlock.DirectedWaterLoggable SIGN_MODLOGO = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1000f).sound(SoundType.WOOD).func_235838_a_((state)->1).notSolid(), + Auxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_decor")); + + public static final DecorBlock.DirectedWaterLoggable SIGN_HOTWIRE = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_hotwire")); + + public static final DecorBlock.DirectedWaterLoggable SIGN_DANGER = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_danger")); + + public static final DecorBlock.DirectedWaterLoggable SIGN_DEFENSE = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_defense")); + + public static final DecorBlock.DirectedWaterLoggable SIGN_FACTORY_AREA = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_factoryarea")); + + public static final DecorBlock.DirectedWaterLoggable SIGN_EXIT = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(3,7,15.6, 13,13,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_exit")); + + // ------------------------------------------------------------------------------------------------------------------- + + @Deprecated // @todo: rename to "crafting_table" in 1.16.2 or 1.17 + public static final EdCraftingTable.CraftingTableBlock CRAFTING_TABLE = (EdCraftingTable.CraftingTableBlock)(new EdCraftingTable.CraftingTableBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(0,15,0, 16,16,16), + Auxiliaries.getPixeledAABB(1, 0,1, 15,16,15) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_crafting_table")); + + public static final FurnaceBlock SMALL_LAB_FURNACE = (FurnaceBlock)(new FurnaceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(1,0,1, 15, 1,15), + Auxiliaries.getPixeledAABB(0,1,1, 16,16,16), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_lab_furnace")); + + public static final EdElectricalFurnace.ElectricalFurnaceBlock SMALL_ELECTRICAL_FURNACE = (EdElectricalFurnace.ElectricalFurnaceBlock)(new EdElectricalFurnace.ElectricalFurnaceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(0, 0,0, 16,11,16), + Auxiliaries.getPixeledAABB(1,11,0, 15,12,16), + Auxiliaries.getPixeledAABB(2,12,0, 14,13,16), + Auxiliaries.getPixeledAABB(3,13,0, 13,14,16), + Auxiliaries.getPixeledAABB(4,14,0, 12,16,16), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_electrical_furnace")); + + public static final EdDropper.DropperBlock FACTORY_DROPPER = (EdDropper.DropperBlock)(new EdDropper.DropperBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,0,1, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_dropper")); + + public static final EdPlacer.PlacerBlock FACTORY_PLACER = (EdPlacer.PlacerBlock)(new EdPlacer.PlacerBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_SHIFTCLICK|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(0,0,2, 16,16,16), + Auxiliaries.getPixeledAABB( 0,0,0, 1,16, 2), + Auxiliaries.getPixeledAABB(15,0,0,16,16, 2) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_placer")); + + public static final EdBreaker.BreakerBlock SMALL_BLOCK_BREAKER = (EdBreaker.BreakerBlock)(new EdBreaker.BreakerBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_SHIFTCLICK, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(1,0,0, 15, 4, 7), + Auxiliaries.getPixeledAABB(1,0,7, 15,12,16), + Auxiliaries.getPixeledAABB(0,0,0, 1, 5, 4), + Auxiliaries.getPixeledAABB(0,0,4, 1,12,16), + Auxiliaries.getPixeledAABB(15,0,0, 16, 5, 4), + Auxiliaries.getPixeledAABB(15,0,4, 16,12,16) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_block_breaker")); + + public static final EdHopper.HopperBlock FACTORY_HOPPER = (EdHopper.HopperBlock)(new EdHopper.HopperBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(),()->{ + final AxisAlignedBB[] down_aabbs = new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 5, 0, 5, 11, 1,11), + Auxiliaries.getPixeledAABB( 4, 1, 4, 12, 7,12), + Auxiliaries.getPixeledAABB( 2, 7, 2, 14,10,14), + Auxiliaries.getPixeledAABB( 0,10, 0, 16,16,16), + Auxiliaries.getPixeledAABB( 0, 4, 5, 2,10,11), + Auxiliaries.getPixeledAABB(14, 4, 5, 16,10,11), + Auxiliaries.getPixeledAABB( 5, 4, 0, 11,10, 2), + Auxiliaries.getPixeledAABB( 5, 4,14, 11,10,16), + }; + final AxisAlignedBB[] up_aabbs = new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 5,15, 5, 11,16,11), + Auxiliaries.getPixeledAABB( 4,14, 4, 12, 9,12), + Auxiliaries.getPixeledAABB( 2, 9, 2, 14, 6,14), + Auxiliaries.getPixeledAABB( 0, 6, 0, 16, 0,16), + Auxiliaries.getPixeledAABB( 0,12, 5, 2, 6,11), + Auxiliaries.getPixeledAABB(14,12, 5, 16, 6,11), + Auxiliaries.getPixeledAABB( 5,12, 0, 11, 6, 2), + Auxiliaries.getPixeledAABB( 5,12,14, 11, 6,16), + }; + final AxisAlignedBB[] north_aabbs = new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 5, 0, 5, 11, 1,11), + Auxiliaries.getPixeledAABB( 4, 1, 4, 12, 7,12), + Auxiliaries.getPixeledAABB( 2, 7, 2, 14,10,14), + Auxiliaries.getPixeledAABB( 0,10, 0, 16,16,16), + Auxiliaries.getPixeledAABB( 0, 4, 5, 2,10,11), + Auxiliaries.getPixeledAABB(14, 4, 5, 16,10,11), + Auxiliaries.getPixeledAABB( 5, 1, 0, 11, 7, 4), + Auxiliaries.getPixeledAABB( 5, 4,14, 11,10,16), + }; + return new ArrayList(Arrays.asList( + Auxiliaries.getUnionShape(down_aabbs), + Auxiliaries.getUnionShape(up_aabbs), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(north_aabbs, Direction.NORTH, false)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(north_aabbs, Direction.SOUTH, false)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(north_aabbs, Direction.WEST, false)), + Auxiliaries.getUnionShape(Auxiliaries.getRotatedAABB(north_aabbs, Direction.EAST, false)), + VoxelShapes.fullCube(), + VoxelShapes.fullCube() + )); + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "factory_hopper")); + + public static final EdWasteIncinerator.WasteIncineratorBlock SMALL_WASTE_INCINERATOR = (EdWasteIncinerator.WasteIncineratorBlock)(new EdWasteIncinerator.WasteIncineratorBlock( + DecorBlock.CFG_DEFAULT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL), + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_waste_incinerator")); + + public static final EdMineralSmelter.MineralSmelterBlock SMALL_MINERAL_SMELTER = (EdMineralSmelter.MineralSmelterBlock)(new EdMineralSmelter.MineralSmelterBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(1.1,0,1.1, 14.9,16,14.9) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_mineral_smelter")); + + public static final EdSolarPanel.SolarPanelBlock SMALL_SOLAR_PANEL = (EdSolarPanel.SolarPanelBlock)(new EdSolarPanel.SolarPanelBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(0,0,0, 16,2,16), + Auxiliaries.getPixeledAABB(6,1.5,3, 10,10.5,13), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_solar_panel")); + + public static final EdMilker.MilkerBlock SMALL_MILKING_MACHINE = (EdMilker.MilkerBlock)(new EdMilker.MilkerBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 1, 1,0, 15,14,10), + Auxiliaries.getPixeledAABB( 0,14,0, 16,16,13), + Auxiliaries.getPixeledAABB( 0, 0,0, 16, 1,13), + Auxiliaries.getPixeledAABB( 0, 1,1, 1,14,11), + Auxiliaries.getPixeledAABB(15, 1,1, 16,14,11) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_milking_machine")); + + public static final EdTreeCutter.TreeCutterBlock SMALL_TREE_CUTTER = (EdTreeCutter.TreeCutterBlock)(new EdTreeCutter.TreeCutterBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_SHIFTCLICK, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 0,0, 0, 16,3,16), + Auxiliaries.getPixeledAABB( 0,3, 0, 3,8,16), + Auxiliaries.getPixeledAABB( 3,7, 0, 5,8,16), + Auxiliaries.getPixeledAABB(15,0, 0, 16,6,16), + Auxiliaries.getPixeledAABB( 0,0,13, 16,8,16), + Auxiliaries.getPixeledAABB( 5,6,12, 16,8,13), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_tree_cutter")); + + public static final EdPipeValve.PipeValveBlock STRAIGHT_CHECK_VALVE = (EdPipeValve.PipeValveBlock)(new EdPipeValve.PipeValveBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_SHIFTCLICK, + EdPipeValve.CFG_CHECK_VALVE, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(2,2, 0, 14,14, 2), + Auxiliaries.getPixeledAABB(2,2,14, 14,14,16), + Auxiliaries.getPixeledAABB(3,3, 5, 13,13,11), + Auxiliaries.getPixeledAABB(4,4, 2, 12,12,14), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve")); + + public static final EdPipeValve.PipeValveBlock STRAIGHT_REDSTONE_VALVE = (EdPipeValve.PipeValveBlock)(new EdPipeValve.PipeValveBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + EdPipeValve.CFG_REDSTONE_CONTROLLED_VALVE, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(2,2, 0, 14,14, 2), + Auxiliaries.getPixeledAABB(2,2,14, 14,14,16), + Auxiliaries.getPixeledAABB(3,3, 5, 13,13,11), + Auxiliaries.getPixeledAABB(4,4, 2, 12,12,14), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone")); + + public static final EdPipeValve.PipeValveBlock STRAIGHT_REDSTONE_ANALOG_VALVE = (EdPipeValve.PipeValveBlock)(new EdPipeValve.PipeValveBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + EdPipeValve.CFG_REDSTONE_CONTROLLED_VALVE|EdPipeValve.CFG_ANALOG_VALVE, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(2,2, 0, 14,14, 2), + Auxiliaries.getPixeledAABB(2,2,14, 14,14,16), + Auxiliaries.getPixeledAABB(3,3, 5, 13,13,11), + Auxiliaries.getPixeledAABB(4,4, 2, 12,12,14), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "straight_pipe_valve_redstone_analog")); + + public static final EdFluidAccumulator.FluidAccumulatorBlock PASSIVE_FLUID_ACCUMULATOR = (EdFluidAccumulator.FluidAccumulatorBlock)(new EdFluidAccumulator.FluidAccumulatorBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(3,3,0, 13,13, 1), + Auxiliaries.getPixeledAABB(0,0,1, 16,16,16) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "passive_fluid_accumulator")); + + public static final EdFluidBarrel.FluidBarrelBlock FLUID_BARREL = (EdFluidBarrel.FluidBarrelBlock)(new EdFluidBarrel.FluidBarrelBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(2, 0,0, 14, 1,16), + Auxiliaries.getPixeledAABB(1, 1,0, 15, 2,16), + Auxiliaries.getPixeledAABB(0, 2,0, 16,14,16), + Auxiliaries.getPixeledAABB(1,14,0, 15,15,16), + Auxiliaries.getPixeledAABB(2,15,0, 14,16,16), + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "fluid_barrel")); + + public static final EdFluidFunnel.FluidFunnelBlock SMALL_FLUID_FUNNEL = (EdFluidFunnel.FluidFunnelBlock)(new EdFluidFunnel.FluidFunnelBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(0, 0,0, 16,14,16), + Auxiliaries.getPixeledAABB(1,14,1, 15,15,15), + Auxiliaries.getPixeledAABB(0,15,0, 16,16,16) + } + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "small_fluid_funnel")); + + public static final EdLabeledCrate.LabeledCrateBlock LABELED_CRATE = (EdLabeledCrate.LabeledCrateBlock)(new EdLabeledCrate.LabeledCrateBlock( + DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(0.5f, 128f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "labeled_crate")); + + // ------------------------------------------------------------------------------------------------------------------- + + //todo: REMOVE IN 1.17/1.16.2 + @Deprecated + public static final EdWallBlock CONCRETE_WALL = (EdWallBlock)(new EdWallBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 50f).sound(SoundType.STONE).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "concrete_wall")); + + public static final EdSlabSliceBlock HALFSLAB_CONCRETE = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(1f, 10f).sound(SoundType.STONE).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_concrete")); + + public static final EdSlabSliceBlock HALFSLAB_TREATEDWOOD = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 4f).sound(SoundType.WOOD).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_treated_wood")); + + public static final EdSlabSliceBlock HALFSLAB_SHEETMETALIRON = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 10f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_sheetmetal_iron")); + + public static final EdSlabSliceBlock HALFSLAB_SHEETMETALSTEEL = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 10f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_sheetmetal_steel")); + + public static final EdSlabSliceBlock HALFSLAB_SHEETMETALCOPPER = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 10f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_sheetmetal_copper")); + + public static final EdSlabSliceBlock HALFSLAB_SHEETMETALGOLD = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 10f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_sheetmetal_gold")); + + public static final EdSlabSliceBlock HALFSLAB_SHEETMETALALUMINIUM = (EdSlabSliceBlock)(new EdSlabSliceBlock( + DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HARD_IE_DEPENDENT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1f, 10f).sound(SoundType.METAL).notSolid() + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "halfslab_sheetmetal_aluminum")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdFenceBlock STEEL_MESH_FENCE = (EdFenceBlock)(new EdFenceBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + 1.5, 16, 0.25, 0, 16, 16 + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_mesh_fence")); + + public static final EdDoubleGateBlock STEEL_MESH_FENCE_GATE = (EdDoubleGateBlock)(new EdDoubleGateBlock( + DecorBlock.CFG_CUTOUT, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,0,6.5, 16,16,9.5) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "steel_mesh_fence_gate")); + + // ------------------------------------------------------------------------------------------------------------------- + + public static final EdTestBlock.TestBlock TEST_BLOCK = (EdTestBlock.TestBlock)(new EdTestBlock.TestBlock( + DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_SHIFTCLICK, + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(0f, 32000f).sound(SoundType.METAL).notSolid(), + Auxiliaries.getPixeledAABB(0,0,0, 16,16,16) + )).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "test_block")); + + // ------------------------------------------------------------------------------------------------------------------- + + private static final Block modBlocks[] = { + CRAFTING_TABLE, + LABELED_CRATE, + SMALL_LAB_FURNACE, + SMALL_ELECTRICAL_FURNACE, + FACTORY_HOPPER, + FACTORY_DROPPER, + FACTORY_PLACER, + SMALL_BLOCK_BREAKER, + SMALL_TREE_CUTTER, + SMALL_SOLAR_PANEL, + SMALL_WASTE_INCINERATOR, + SMALL_MINERAL_SMELTER, + SMALL_MILKING_MACHINE, + FLUID_BARREL, + STRAIGHT_CHECK_VALVE, + STRAIGHT_REDSTONE_VALVE, + STRAIGHT_REDSTONE_ANALOG_VALVE, + PASSIVE_FLUID_ACCUMULATOR, + SMALL_FLUID_FUNNEL, + DENSE_GRIT_SAND, + DENSE_GRIT_DIRT, + CLINKER_BRICK_BLOCK, + CLINKER_BRICK_SLAB, + CLINKER_BRICK_STAIRS, + CLINKER_BRICK_WALL, + CLINKER_BRICK_STAINED_BLOCK, + CLINKER_BRICK_STAINED_SLAB, + CLINKER_BRICK_STAINED_STAIRS, + SLAG_BRICK_BLOCK, + SLAG_BRICK_SLAB, + SLAG_BRICK_STAIRS, + SLAG_BRICK_WALL, + REBAR_CONCRETE_BLOCK, + REBAR_CONCRETE_SLAB, + REBAR_CONCRETE_STAIRS, + REBAR_CONCRETE_WALL, + REBAR_CONCRETE_TILE, + REBAR_CONCRETE_TILE_SLAB, + REBAR_CONCRETE_TILE_STAIRS, + GAS_CONCRETE_BLOCK, + GAS_CONCRETE_SLAB, + GAS_CONCRETE_STAIRS, + GAS_CONCRETE_WALL, + HALFSLAB_REBARCONCRETE, + HALFSLAB_GASCONCRETE, + HALFSLAB_CONCRETE, + HALFSLAB_TREATEDWOOD, + HALFSLAB_SHEETMETALIRON, + HALFSLAB_SHEETMETALSTEEL, + HALFSLAB_SHEETMETALCOPPER, + HALFSLAB_SHEETMETALGOLD, + HALFSLAB_SHEETMETALALUMINIUM, + CONCRETE_WALL, + PANZERGLASS_BLOCK, + PANZERGLASS_SLAB, + METAL_RUNG_LADDER, + METAL_RUNG_STEPS, + TREATED_WOOD_LADDER, + IRON_HATCH, + TREATED_WOOD_TABLE, + TREATED_WOOD_STOOL, + TREATED_WOOD_SIDE_TABLE, + TREATED_WOOD_WINDOWSILL, + TREATED_WOOD_BROAD_WINDOWSILL, + TREATED_WOOD_WINDOW, + STEEL_FRAMED_WINDOW, + STEEL_TABLE, + INSET_LIGHT_IRON, + FLOOR_EDGE_LIGHT_IRON, + CEILING_EDGE_LIGHT_IRON, + BULB_LIGHT_IRON, + STEEL_FLOOR_GRATING, + STEEL_MESH_FENCE, + STEEL_MESH_FENCE_GATE, + TREATED_WOOD_POLE, + TREATED_WOOD_POLE_HEAD, + TREATED_WOOD_POLE_SUPPORT, + THIN_STEEL_POLE, + THIN_STEEL_POLE_HEAD, + THICK_STEEL_POLE, + THICK_STEEL_POLE_HEAD, + STEEL_DOUBLE_T_SUPPORT, + SIGN_HOTWIRE, + SIGN_DANGER, + SIGN_DEFENSE, + SIGN_FACTORY_AREA, + SIGN_EXIT, + SIGN_MODLOGO, + }; + + private static final Block devBlocks[] = { + //TEST_BLOCK + }; + + //-------------------------------------------------------------------------------------------------------------------- + // Tile entities bound exclusively to the blocks above + //-------------------------------------------------------------------------------------------------------------------- + + public static final TileEntityType TET_CRAFTING_TABLE = TileEntityType.Builder + .create(EdCraftingTable.CraftingTableTileEntity::new, CRAFTING_TABLE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_treated_wood_crafting_table"); + + public static final TileEntityType TET_LABELED_CRATE = TileEntityType.Builder + .create(EdLabeledCrate.LabeledCrateTileEntity::new, LABELED_CRATE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_labeled_crate"); + + public static final TileEntityType TET_SMALL_LAB_FURNACE = TileEntityType.Builder + .create(FurnaceTileEntity::new, SMALL_LAB_FURNACE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_lab_furnace"); + + public static final TileEntityType TET_SMALL_ELECTRICAL_FURNACE = TileEntityType.Builder + .create(EdElectricalFurnace.ElectricalFurnaceTileEntity::new, SMALL_ELECTRICAL_FURNACE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_electrical_furnace"); + + public static final TileEntityType TET_FACTORY_DROPPER = TileEntityType.Builder + .create(EdDropper.DropperTileEntity::new, FACTORY_DROPPER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_factory_dropper"); + + public static final TileEntityType TET_FACTORY_PLACER = TileEntityType.Builder + .create(EdPlacer.PlacerTileEntity::new, FACTORY_PLACER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_factory_placer"); + + public static final TileEntityType TET_SMALL_BLOCK_BREAKER = TileEntityType.Builder + .create(EdBreaker.BreakerTileEntity::new, SMALL_BLOCK_BREAKER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_block_breaker"); + + public static final TileEntityType TET_FACTORY_HOPPER = TileEntityType.Builder + .create(EdHopper.HopperTileEntity::new, FACTORY_HOPPER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_factory_hopper"); + + public static final TileEntityType TET_WASTE_INCINERATOR = TileEntityType.Builder + .create(EdWasteIncinerator.WasteIncineratorTileEntity::new, SMALL_WASTE_INCINERATOR) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_waste_incinerator"); + + public static final TileEntityType TET_STRAIGHT_PIPE_VALVE = TileEntityType.Builder + .create(EdPipeValve.PipeValveTileEntity::new, STRAIGHT_CHECK_VALVE, STRAIGHT_REDSTONE_VALVE, STRAIGHT_REDSTONE_ANALOG_VALVE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_pipe_valve"); + + public static final TileEntityType TET_PASSIVE_FLUID_ACCUMULATOR = TileEntityType.Builder + .create(EdFluidAccumulator.FluidAccumulatorTileEntity::new, PASSIVE_FLUID_ACCUMULATOR) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_passive_fluid_accumulator"); + + public static final TileEntityType TET_FLUID_BARREL = TileEntityType.Builder + .create(EdFluidBarrel.FluidBarrelTileEntity::new, FLUID_BARREL) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_fluid_barrel"); + + public static final TileEntityType TET_SMALL_FLUID_FUNNEL = TileEntityType.Builder + .create(EdFluidFunnel.FluidFunnelTileEntity::new, SMALL_FLUID_FUNNEL) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_fluid_funnel"); + + public static final TileEntityType TET_MINERAL_SMELTER = TileEntityType.Builder + .create(EdMineralSmelter.MineralSmelterTileEntity::new, SMALL_MINERAL_SMELTER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_mineral_smelter"); + + public static final TileEntityType TET_SMALL_SOLAR_PANEL = TileEntityType.Builder + .create(EdSolarPanel.SolarPanelTileEntity::new, SMALL_SOLAR_PANEL) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_solar_panel"); + + public static final TileEntityType TET_SMALL_MILKING_MACHINE = TileEntityType.Builder + .create(EdMilker.MilkerTileEntity::new, SMALL_MILKING_MACHINE) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_milking_machine"); + + public static final TileEntityType TET_SMALL_TREE_CUTTER = TileEntityType.Builder + .create(EdTreeCutter.TreeCutterTileEntity::new, SMALL_TREE_CUTTER) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_small_tree_cutter"); + + public static final TileEntityType TET_TEST_BLOCK = TileEntityType.Builder + .create(EdTestBlock.TestTileEntity::new, TEST_BLOCK) + .build(null) + .setRegistryName(ModEngineersDecor.MODID, "te_test_block"); + + private static final TileEntityType tile_entity_types[] = { + TET_CRAFTING_TABLE, + TET_LABELED_CRATE, + TET_SMALL_LAB_FURNACE, + TET_SMALL_ELECTRICAL_FURNACE, + TET_FACTORY_HOPPER, + TET_FACTORY_DROPPER, + TET_FACTORY_PLACER, + TET_SMALL_BLOCK_BREAKER, + TET_SMALL_TREE_CUTTER, + TET_WASTE_INCINERATOR, + TET_MINERAL_SMELTER, + TET_SMALL_SOLAR_PANEL, + TET_SMALL_MILKING_MACHINE, + TET_STRAIGHT_PIPE_VALVE, + TET_FLUID_BARREL, + TET_PASSIVE_FLUID_ACCUMULATOR, + TET_SMALL_FLUID_FUNNEL, + TET_TEST_BLOCK + }; + + //-------------------------------------------------------------------------------------------------------------------- + // Entities bound exclusively to the blocks above + //-------------------------------------------------------------------------------------------------------------------- + + @SuppressWarnings("unchecked") + public static final EntityType ET_CHAIR = (EntityType)( + EntityType.Builder + .create(EdChair.EntityChair::new, EntityClassification.MISC) + .immuneToFire().size(1e-3f, 1e-3f).disableSerialization() + .setShouldReceiveVelocityUpdates(false).setUpdateInterval(4) + .setCustomClientFactory(EdChair.EntityChair::customClientFactory) + .build(new ResourceLocation(ModEngineersDecor.MODID, "et_chair").toString()) + .setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "et_chair")) + ); + + private static final EntityType entity_types[] = { + ET_CHAIR + }; + + //-------------------------------------------------------------------------------------------------------------------- + // Container registration + //-------------------------------------------------------------------------------------------------------------------- + + public static final ContainerType CT_TREATED_WOOD_CRAFTING_TABLE; + public static final ContainerType CT_FACTORY_DROPPER; + public static final ContainerType CT_FACTORY_PLACER; + public static final ContainerType CT_FACTORY_HOPPER; + public static final ContainerType CT_SMALL_LAB_FURNACE; + public static final ContainerType CT_SMALL_ELECTRICAL_FURNACE; + public static final ContainerType CT_WASTE_INCINERATOR; + public static final ContainerType CT_LABELED_CRATE; + + static { + CT_TREATED_WOOD_CRAFTING_TABLE = (new ContainerType(EdCraftingTable.CraftingTableContainer::new)); + CT_TREATED_WOOD_CRAFTING_TABLE.setRegistryName(ModEngineersDecor.MODID,"ct_treated_wood_crafting_table"); + CT_FACTORY_DROPPER = (new ContainerType(EdDropper.DropperContainer::new)); + CT_FACTORY_DROPPER.setRegistryName(ModEngineersDecor.MODID,"ct_factory_dropper"); + CT_FACTORY_PLACER = (new ContainerType(EdPlacer.PlacerContainer::new)); + CT_FACTORY_PLACER.setRegistryName(ModEngineersDecor.MODID,"ct_factory_placer"); + CT_FACTORY_HOPPER = (new ContainerType(EdHopper.HopperContainer::new)); + CT_FACTORY_HOPPER.setRegistryName(ModEngineersDecor.MODID,"ct_factory_hopper"); + CT_SMALL_LAB_FURNACE = (new ContainerType(FurnaceContainer::new)); + CT_SMALL_LAB_FURNACE.setRegistryName(ModEngineersDecor.MODID,"ct_small_lab_furnace"); + CT_SMALL_ELECTRICAL_FURNACE = (new ContainerType(EdElectricalFurnace.ElectricalFurnaceContainer::new)); + CT_SMALL_ELECTRICAL_FURNACE.setRegistryName(ModEngineersDecor.MODID,"ct_small_electrical_furnace"); + CT_WASTE_INCINERATOR = (new ContainerType(EdWasteIncinerator.WasteIncineratorContainer::new)); + CT_WASTE_INCINERATOR.setRegistryName(ModEngineersDecor.MODID,"ct_small_waste_incinerator"); + CT_LABELED_CRATE = (new ContainerType(EdLabeledCrate.LabeledCrateContainer::new)); + CT_LABELED_CRATE.setRegistryName(ModEngineersDecor.MODID,"ct_labeled_crate"); + } + + // DON'T FORGET TO REGISTER THE GUI in registerContainerGuis(), no list/map format found yet for that. + private static final ContainerType container_types[] = { + CT_TREATED_WOOD_CRAFTING_TABLE, + CT_LABELED_CRATE, + CT_FACTORY_DROPPER, + CT_FACTORY_PLACER, + CT_FACTORY_HOPPER, + CT_SMALL_LAB_FURNACE, + CT_SMALL_ELECTRICAL_FURNACE, + CT_WASTE_INCINERATOR + }; + + //-------------------------------------------------------------------------------------------------------------------- + // Initialisation events + //-------------------------------------------------------------------------------------------------------------------- + + private static ArrayList registeredBlocks = new ArrayList<>(); + + public static ArrayList allBlocks() + { + ArrayList blocks = new ArrayList<>(); + Collections.addAll(blocks, modBlocks); + Collections.addAll(blocks, devBlocks); + return blocks; + } + + public static boolean isExperimentalBlock(Block block) + { return ArrayUtils.contains(devBlocks, block); } + + @Nonnull + public static List getRegisteredBlocks() + { return Collections.unmodifiableList(registeredBlocks); } + + @Nonnull + public static List getRegisteredItems() + { return new ArrayList<>(); } + + public static final void registerBlocks(final RegistryEvent.Register event) + { + boolean ie_available = Auxiliaries.isModLoaded("immersiveengineering"); + if(ie_available) { + Auxiliaries.logInfo("Immersive Engineering also installed ..."); + registeredBlocks.addAll(allBlocks()); + } else { + registeredBlocks.addAll(allBlocks().stream() + .filter(block-> + ((!(block instanceof IDecorBlock)) || ((((IDecorBlock)block).config() & DecorBlock.CFG_HARD_IE_DEPENDENT)==0)) + ) + .collect(Collectors.toList()) + ); + } + for(Block e:registeredBlocks) event.getRegistry().register(e); + Auxiliaries.logInfo("Registered " + Integer.toString(registeredBlocks.size()) + " blocks."); + } + + public static final void registerBlockItems(final RegistryEvent.Register event) + { + int n = 0; + for(Block e:registeredBlocks) { + ResourceLocation rl = e.getRegistryName(); + if(rl == null) continue; + if(e instanceof StandardBlocks.IBlockItemFactory) { + event.getRegistry().register(((StandardBlocks.IBlockItemFactory)e).getBlockItem(e, (new BlockItem.Properties().group(ModEngineersDecor.ITEMGROUP))).setRegistryName(rl)); + } else { + event.getRegistry().register(new BlockItem(e, (new BlockItem.Properties().group(ModEngineersDecor.ITEMGROUP))).setRegistryName(rl)); + } + ++n; + } + } + + public static final void registerTileEntities(final RegistryEvent.Register> event) + { + int n_registered = 0; + for(final TileEntityType e:tile_entity_types) { + event.getRegistry().register(e); + ++n_registered; + } + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " tile entities."); + } + + public static final void registerEntities(final RegistryEvent.Register> event) + { + int n_registered = 0; + for(final EntityType e:entity_types) { + if((e==ET_CHAIR) && (!registeredBlocks.contains(TREATED_WOOD_STOOL))) continue; + event.getRegistry().register(e); + ++n_registered; + } + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " entities bound to blocks."); + } + + public static final void registerContainers(final RegistryEvent.Register> event) + { + int n_registered = 0; + for(final ContainerType e:container_types) { + event.getRegistry().register(e); + ++n_registered; + } + Auxiliaries.logInfo("Registered " + Integer.toString(n_registered) + " containers bound to tile entities."); + } + + @OnlyIn(Dist.CLIENT) + public static final void registerContainerGuis(final FMLClientSetupEvent event) + { + ScreenManager.registerFactory(CT_TREATED_WOOD_CRAFTING_TABLE, EdCraftingTable.CraftingTableGui::new); + ScreenManager.registerFactory(CT_LABELED_CRATE, EdLabeledCrate.LabeledCrateGui::new); + ScreenManager.registerFactory(CT_FACTORY_DROPPER, EdDropper.DropperGui::new); + ScreenManager.registerFactory(CT_FACTORY_PLACER, EdPlacer.PlacerGui::new); + ScreenManager.registerFactory(CT_FACTORY_HOPPER, EdHopper.HopperGui::new); + ScreenManager.registerFactory(CT_SMALL_LAB_FURNACE, FurnaceGui::new); + ScreenManager.registerFactory(CT_SMALL_ELECTRICAL_FURNACE, EdElectricalFurnace.ElectricalFurnaceGui::new); + ScreenManager.registerFactory(CT_WASTE_INCINERATOR, EdWasteIncinerator.WasteIncineratorGui::new); + } + + @OnlyIn(Dist.CLIENT) + @SuppressWarnings("unchecked") + public static final void registerTileEntityRenderers(final FMLClientSetupEvent event) + { + ClientRegistry.bindTileEntityRenderer( + (TileEntityType)TET_CRAFTING_TABLE, + wile.engineersdecor.detail.ModRenderers.CraftingTableTer::new + ); + ClientRegistry.bindTileEntityRenderer( + (TileEntityType)TET_LABELED_CRATE, + wile.engineersdecor.detail.ModRenderers.DecorLabeledCrateTer::new + ); + } + + @OnlyIn(Dist.CLIENT) + public static final void processContentClientSide(final FMLClientSetupEvent event) + { + // Block renderer selection + for(Block block: getRegisteredBlocks()) { + if(block instanceof IStandardBlock) { + switch(((IStandardBlock)block).getRenderTypeHint()) { + case CUTOUT: + RenderTypeLookup.setRenderLayer(block, RenderType.getCutout()); + break; + case CUTOUT_MIPPED: + RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped()); + break; + case TRANSLUCENT: + RenderTypeLookup.setRenderLayer(block, RenderType.getTranslucent()); + break; + case TRANSLUCENT_NO_CRUMBLING: + RenderTypeLookup.setRenderLayer(block, RenderType.getTranslucentNoCrumbling()); + break; + case SOLID: + break; + } + } + } + // Entity renderers + RenderingRegistry.registerEntityRenderingHandler(ET_CHAIR, + manager->(new wile.engineersdecor.detail.ModRenderers.InvisibleEntityRenderer(manager)) + ); + } + +} diff --git a/src/main/java/wile/engineersdecor/ModEngineersDecor.java b/src/main/java/wile/engineersdecor/ModEngineersDecor.java new file mode 100644 index 0000000..efa52b1 --- /dev/null +++ b/src/main/java/wile/engineersdecor/ModEngineersDecor.java @@ -0,0 +1,165 @@ +package wile.engineersdecor; + +import wile.engineersdecor.blocks.*; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.OptionalRecipeCondition; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.item.ItemGroup; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.*; +import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +@Mod("engineersdecor") +public class ModEngineersDecor +{ + public static final String MODID = "engineersdecor"; + public static final String MODNAME = "Engineer's Decor"; + public static final int VERSION_DATAFIXER = 0; + private static final Logger LOGGER = LogManager.getLogger(); + private static boolean config_loaded = false; + + public ModEngineersDecor() + { + Auxiliaries.init(MODID, LOGGER, ModConfig::getServerConfig); + Auxiliaries.logGitVersion(MODNAME); + OptionalRecipeCondition.init(MODID, LOGGER); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSendImc); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRecvImc); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup); + ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.SERVER, ModConfig.SERVER_CONFIG_SPEC); + ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.CLIENT, ModConfig.CLIENT_CONFIG_SPEC); + MinecraftForge.EVENT_BUS.register(this); + } + + public static final Logger logger() { return LOGGER; } + + // + // Events + // + + private void onSetup(final FMLCommonSetupEvent event) + { + LOGGER.info("Registering recipe condition processor ..."); + CraftingHelper.register(OptionalRecipeCondition.Serializer.INSTANCE); + wile.engineersdecor.libmc.detail.Networking.init(MODID); + if(config_loaded) { + try { + logger().info("Applying loaded config file."); + ModConfig.apply(); + } catch(Throwable e) { + logger().error("Failed to apply config: " + e.getMessage()); + } + } else { + logger().info("Cannot apply config, load event was not casted yet."); + } + } + + private void onClientSetup(final FMLClientSetupEvent event) + { + ModContent.registerContainerGuis(event); + ModContent.registerTileEntityRenderers(event); + ModContent.processContentClientSide(event); + wile.engineersdecor.libmc.detail.Overlay.register(); + } + + private void onSendImc(final InterModEnqueueEvent event) + { + InterModComms.sendTo("inventorysorter", "containerblacklist", ()->ModContent.CT_TREATED_WOOD_CRAFTING_TABLE.getRegistryName()); + InterModComms.sendTo("inventorysorter", "slotblacklist", ()-> EdCraftingTable.CraftingOutputSlot.class.getName()); + InterModComms.sendTo("inventorysorter", "slotblacklist", ()-> EdCraftingTable.CraftingGridSlot.class.getName()); + } + + private void onRecvImc(final InterModProcessEvent event) + {} + + @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) + public static class ForgeEvents + { + @SubscribeEvent + public static void onBlocksRegistry(final RegistryEvent.Register event) + { ModContent.registerBlocks(event); } + + @SubscribeEvent + public static void onItemRegistry(final RegistryEvent.Register event) + { ModContent.registerBlockItems(event); } + + @SubscribeEvent + public static void onTileEntityRegistry(final RegistryEvent.Register> event) + { ModContent.registerTileEntities(event); } + + @SubscribeEvent + public static void onRegisterEntityTypes(final RegistryEvent.Register> event) + { ModContent.registerEntities(event); } + + @SubscribeEvent + public static void onRegisterContainerTypes(final RegistryEvent.Register> event) + { ModContent.registerContainers(event); } + + // @SubscribeEvent + public static void onServerStarting(FMLServerStartingEvent event) + {} + + @SubscribeEvent + public static void onConfigLoad(net.minecraftforge.fml.config.ModConfig.Loading configEvent) + { config_loaded = true; } + + @SubscribeEvent + public static void onConfigReload(net.minecraftforge.fml.config.ModConfig.Reloading configEvent) + { + try { + ModEngineersDecor.logger().info("Config file changed {}", configEvent.getConfig().getFileName()); + ModConfig.apply(); + } catch(Throwable e) { + ModEngineersDecor.logger().error("Failed to load changed config: " + e.getMessage()); + } + } + + @SubscribeEvent + public static void onDataGeneration(GatherDataEvent event) + { + event.getGenerator().addProvider(new wile.engineersdecor.libmc.datagen.LootTableGen(event.getGenerator(), ModContent::allBlocks)); + } + } + + // + // Item group / creative tab + // + public static final ItemGroup ITEMGROUP = (new ItemGroup("tab" + MODID) { + @OnlyIn(Dist.CLIENT) + public ItemStack createIcon() + { return new ItemStack(ModContent.SIGN_MODLOGO); } + }); + + // + // Player update event + // + @SubscribeEvent + public void onPlayerEvent(final LivingEvent.LivingUpdateEvent event) + { + if(!(event.getEntity() instanceof PlayerEntity)) return; + final PlayerEntity player = (PlayerEntity)event.getEntity(); + if(player.world == null) return; + if(player.isOnLadder()) EdLadderBlock.onPlayerUpdateEvent(player); + } + +} diff --git a/src/main/java/wile/engineersdecor/blocks/DecorBlock.java b/src/main/java/wile/engineersdecor/blocks/DecorBlock.java new file mode 100644 index 0000000..fa06d6c --- /dev/null +++ b/src/main/java/wile/engineersdecor/blocks/DecorBlock.java @@ -0,0 +1,119 @@ +/* + * @file DecorBlock.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Common functionality class for decor blocks. + * Mainly needed for: + * - MC block defaults. + * - Tooltip functionality + * - Model initialisation + */ +package wile.engineersdecor.blocks; + +import wile.engineersdecor.libmc.blocks.StandardBlocks; +import wile.engineersdecor.libmc.blocks.StandardBlocks.IStandardBlock; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import net.minecraft.block.IWaterLoggable; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.block.Block; +import java.util.ArrayList; +import java.util.function.Supplier; + + +public class DecorBlock +{ + public static final long CFG_DEFAULT = StandardBlocks.CFG_DEFAULT; + public static final long CFG_CUTOUT = StandardBlocks.CFG_CUTOUT; + public static final long CFG_MIPPED = StandardBlocks.CFG_MIPPED; + public static final long CFG_TRANSLUCENT = StandardBlocks.CFG_TRANSLUCENT; + public static final long CFG_WATERLOGGABLE = StandardBlocks.CFG_WATERLOGGABLE; + public static final long CFG_HORIZIONTAL = StandardBlocks.CFG_HORIZIONTAL; + public static final long CFG_LOOK_PLACEMENT = StandardBlocks.CFG_LOOK_PLACEMENT; + public static final long CFG_FACING_PLACEMENT = StandardBlocks.CFG_FACING_PLACEMENT; + public static final long CFG_OPPOSITE_PLACEMENT = StandardBlocks.CFG_OPPOSITE_PLACEMENT; + public static final long CFG_FLIP_PLACEMENT_IF_SAME = StandardBlocks.CFG_FLIP_PLACEMENT_IF_SAME; + public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = StandardBlocks.CFG_FLIP_PLACEMENT_SHIFTCLICK; + public static final long CFG_STRICT_CONNECTIONS = StandardBlocks.CFG_STRICT_CONNECTIONS; + public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; + + public static class Normal extends StandardBlocks.BaseBlock implements IDecorBlock + { + public Normal(long conf, Block.Properties properties) + { super(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); } + + public Normal(long conf, Block.Properties properties, AxisAlignedBB aabb) + { super(conf, properties, aabb);} + + public Normal(long conf, Block.Properties properties, VoxelShape voxel_shape) + { super(conf, properties, voxel_shape); } + + public Normal(long conf, Block.Properties properties, AxisAlignedBB[] aabbs) + { super(conf, properties, aabbs); } + } + + public static class WaterLoggable extends StandardBlocks.WaterLoggable implements IStandardBlock, IWaterLoggable + { + public WaterLoggable(long config, Block.Properties properties) + { super(config, properties); } + + public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + + public WaterLoggable(long config, Block.Properties properties, AxisAlignedBB[] aabbs) + { super(config, properties, aabbs); } + + public WaterLoggable(long config, Block.Properties properties, VoxelShape voxel_shape) + { super(config, properties, voxel_shape); } + } + + public static class Directed extends StandardBlocks.Directed implements IDecorBlock + { + public Directed(long config, Block.Properties properties, final AxisAlignedBB unrotatedAABB) + { super(config, properties, unrotatedAABB); } + + public Directed(long config, Block.Properties properties, final AxisAlignedBB[] unrotatedAABBs) + { super(config, properties, unrotatedAABBs); } + + public Directed(long config, Block.Properties properties, final Supplier> shape_supplier) + { super(config, properties, shape_supplier); } + } + + public static class DirectedWaterLoggable extends StandardBlocks.DirectedWaterLoggable implements IDecorBlock,IWaterLoggable + { + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + + public DirectedWaterLoggable(long config, Block.Properties properties, AxisAlignedBB[] aabbs) + { super(config, properties, aabbs); } + + public DirectedWaterLoggable(long config, Block.Properties properties, final Supplier> shape_supplier) + { super(config, properties, shape_supplier); } + } + + public static class Horizontal extends StandardBlocks.Horizontal implements IDecorBlock + { + public Horizontal(long config, Block.Properties properties, final AxisAlignedBB unrotatedAABB) + { super(config, properties, unrotatedAABB); } + + public Horizontal(long config, Block.Properties properties, final AxisAlignedBB[] unrotatedAABBs) + { super(config, properties, unrotatedAABBs); } + + public Horizontal(long config, Block.Properties properties, final Supplier> shape_supplier) + { super(config, properties, shape_supplier); } + } + + public static class HorizontalWaterLoggable extends StandardBlocks.HorizontalWaterLoggable implements IWaterLoggable + { + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB aabb) + { super(config, properties, aabb); } + + public HorizontalWaterLoggable(long config, Block.Properties properties, AxisAlignedBB[] aabbs) + { super(config, properties, aabbs); } + + public HorizontalWaterLoggable(long config, Block.Properties properties, final Supplier> shape_supplier) + { super(config, properties, shape_supplier); } + } +} diff --git a/src/main/java/wile/engineersdecor/blocks/EdBreaker.java b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java new file mode 100644 index 0000000..24a193f --- /dev/null +++ b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java @@ -0,0 +1,360 @@ +/* + * @file EdBreaker.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Small Block Breaker + */ +package wile.engineersdecor.blocks; + +import wile.engineersdecor.ModContent; +import wile.engineersdecor.ModEngineersDecor; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Overlay; +import net.minecraft.world.World; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.GameRules; +import net.minecraft.world.server.ServerWorld; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.block.Blocks; +import net.minecraft.block.SoundType; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.*; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.energy.IEnergyStorage; +import javax.annotation.Nullable; +import java.util.HashSet; +import java.util.List; +import java.util.Random; + + +public class EdBreaker +{ + //-------------------------------------------------------------------------------------------------------------------- + // Block + //-------------------------------------------------------------------------------------------------------------------- + + public static class BreakerBlock extends DecorBlock.HorizontalWaterLoggable implements IDecorBlock + { + public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); + + public BreakerBlock(long config, Block.Properties builder, final AxisAlignedBB[] unrotatedAABBs) + { super(config, builder, unrotatedAABBs); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) + { super.fillStateContainer(builder); builder.add(ACTIVE); } + + @Override + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) + { return super.getStateForPlacement(context).with(ACTIVE, false); } + + @Override + public boolean hasTileEntity(BlockState state) + { return true; } + + @Override + @Nullable + public TileEntity createTileEntity(BlockState state, IBlockReader world) + { return new BreakerTileEntity(); } + + @OnlyIn(Dist.CLIENT) + public void animateTick(BlockState state, World world, BlockPos pos, Random rnd) + { + if((state.getBlock()!=this) || (!state.get(ACTIVE))) return; + final double rv = rnd.nextDouble(); + if(rv > 0.8) return; + final double x=0.5+pos.getX(), y=0.5+pos.getY(), z=0.5+pos.getZ(); + final double xc=0.52, xr=rnd.nextDouble()*0.4-0.2, yr=(y-0.3+rnd.nextDouble()*0.2); + switch(state.get(HORIZONTAL_FACING)) { + case WEST: world.addParticle(ParticleTypes.SMOKE, x-xc, yr, z+xr, 0.0, 0.0, 0.0); break; + case EAST: world.addParticle(ParticleTypes.SMOKE, x+xc, yr, z+xr, 0.0, 0.0, 0.0); break; + case NORTH: world.addParticle(ParticleTypes.SMOKE, x+xr, yr, z-xc, 0.0, 0.0, 0.0); break; + default: world.addParticle(ParticleTypes.SMOKE, x+xr, yr, z+xc, 0.0, 0.0, 0.0); break; + } + } + + @Override + @SuppressWarnings("deprecation") + public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean unused) + { + if(!(world instanceof World) || (((World) world).isRemote)) return; + TileEntity te = world.getTileEntity(pos); + if(!(te instanceof BreakerTileEntity)) return; + ((BreakerTileEntity)te).block_updated(); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canProvidePower(BlockState state) + { return true; } + + @Override + @SuppressWarnings("deprecation") + public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) + { return 0; } + + @Override + @SuppressWarnings("deprecation") + public int getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) + { return 0; } + + @Override + @SuppressWarnings("deprecation") + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) + { + TileEntity te = world.getTileEntity(pos); + if(te instanceof BreakerTileEntity) ((BreakerTileEntity)te).state_message(player); + return ActionResultType.SUCCESS; + } + } + + //-------------------------------------------------------------------------------------------------------------------- + // Tile entity + //-------------------------------------------------------------------------------------------------------------------- + + public static class BreakerTileEntity extends TileEntity implements ITickableTileEntity, IEnergyStorage + { + public static final int IDLE_TICK_INTERVAL = 40; + public static final int TICK_INTERVAL = 5; + public static final int BOOST_FACTOR = 8; + public static final int DEFAULT_BOOST_ENERGY = 64; + public static final int DEFAULT_BREAKING_RELUCTANCE = 17; + public static final int DEFAULT_MIN_BREAKING_TIME = 15; + public static final int MAX_BREAKING_TIME = 800; + private static int boost_energy_consumption = DEFAULT_BOOST_ENERGY; + private static int energy_max = 32000; + private static int breaking_reluctance = DEFAULT_BREAKING_RELUCTANCE; + private static int min_breaking_time = DEFAULT_MIN_BREAKING_TIME; + private static boolean requires_power = false; + private int tick_timer_; + private int active_timer_; + private int proc_time_elapsed_; + private int time_needed_; + private int energy_; + + public static void on_config(int boost_energy_per_tick, int breaking_time_per_hardness, int min_breaking_time_ticks, boolean power_required) + { + boost_energy_consumption = TICK_INTERVAL * MathHelper.clamp(boost_energy_per_tick, 4, 4096); + energy_max = Math.max(boost_energy_consumption * 10, 10000); + breaking_reluctance = MathHelper.clamp(breaking_time_per_hardness, 5, 50); + min_breaking_time = MathHelper.clamp(min_breaking_time_ticks, 10, 100); + requires_power = power_required; + ModEngineersDecor.logger().info("Config block breaker: Boost energy consumption:" + (boost_energy_consumption/TICK_INTERVAL) + "rf/t, reluctance=" + breaking_reluctance + "t/hrdn, break time offset=" + min_breaking_time + "t"); + } + + public BreakerTileEntity() + { super(ModContent.TET_SMALL_BLOCK_BREAKER); } + + public BreakerTileEntity(TileEntityType te_type) + { super(te_type); } + + public void block_updated() + { if(tick_timer_ > 2) tick_timer_ = 2; } + + public void readnbt(CompoundNBT nbt) + { energy_ = nbt.getInt("energy"); } + + private void writenbt(CompoundNBT nbt) + { nbt.putInt("energy", energy_); } + + public void state_message(PlayerEntity player) + { + String progress = "0"; + if((proc_time_elapsed_ > 0) && (time_needed_ > 0)) { + progress = Integer.toString((int)MathHelper.clamp((((double)proc_time_elapsed_) / ((double)time_needed_) * 100), 0, 100)); + } + String soc = Integer.toString(MathHelper.clamp((energy_*100/energy_max),0,100)); + Overlay.show(player, Auxiliaries.localizable("block.engineersdecor.small_block_breaker.status", null, new Object[]{soc, energy_max, progress })); + } + + // TileEntity ------------------------------------------------------------------------------ + + @Override + public void func_230337_a_(BlockState state, CompoundNBT nbt) + { super.func_230337_a_(state, nbt); readnbt(nbt); } + + @Override + public CompoundNBT write(CompoundNBT nbt) + { super.write(nbt); writenbt(nbt); return nbt; } + + @Override + public void remove() + { + super.remove(); + energy_handler_.invalidate(); + } + + // IEnergyStorage ---------------------------------------------------------------------------- + + protected LazyOptional energy_handler_ = LazyOptional.of(() -> (IEnergyStorage)this); + + @Override + public boolean canExtract() + { return false; } + + @Override + public boolean canReceive() + { return true; } + + @Override + public int getMaxEnergyStored() + { return boost_energy_consumption*2; } + + @Override + public int getEnergyStored() + { return energy_; } + + @Override + public int extractEnergy(int maxExtract, boolean simulate) + { return 0; } + + @Override + public int receiveEnergy(int maxReceive, boolean simulate) + { + maxReceive = MathHelper.clamp(maxReceive, 0, Math.max(energy_max-energy_, 0)); + if(!simulate) energy_ += maxReceive; + return maxReceive; + } + + // Capability export ---------------------------------------------------------------------------- + + @Override + public LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) + { + if(capability == CapabilityEnergy.ENERGY) return energy_handler_.cast(); + return super.getCapability(capability, facing); + } + + // ITickable ------------------------------------------------------------------------------------ + + private static HashSet blacklist = new HashSet<>(); + static { + blacklist.add(Blocks.AIR); + blacklist.add(Blocks.BEDROCK); + blacklist.add(Blocks.FIRE); + blacklist.add(Blocks.END_PORTAL); + blacklist.add(Blocks.END_GATEWAY); + blacklist.add(Blocks.END_PORTAL_FRAME); + blacklist.add(Blocks.NETHER_PORTAL); + blacklist.add(Blocks.BARRIER); + } + + private static boolean isBreakable(BlockState state, BlockPos pos, World world) + { + final Block block = state.getBlock(); + if(blacklist.contains(block)) return false; + if(state.getMaterial().isLiquid()) return false; + if(block.isAir(state, world, pos)) return false; + float bh = state.getBlockHardness(world, pos); + if((bh<0) || (bh>55)) return false; + return true; + } + + private static void spawnBlockAsEntity(World world, BlockPos pos, ItemStack stack) { + if(world.isRemote || stack.isEmpty() || (!world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) || world.restoringBlockSnapshots) return; + ItemEntity e = new ItemEntity(world, + ((world.rand.nextFloat()*0.1)+0.5) + pos.getX(), + ((world.rand.nextFloat()*0.1)+0.5) + pos.getY(), + ((world.rand.nextFloat()*0.1)+0.5) + pos.getZ(), + stack + ); + e.setDefaultPickupDelay(); + e.setMotion((world.rand.nextFloat()*0.1-0.05), (world.rand.nextFloat()*0.1-0.03), (world.rand.nextFloat()*0.1-0.05)); + world.addEntity(e); + } + + private boolean breakBlock(BlockState state, BlockPos pos, World world) + { + if(world.isRemote || (!(world instanceof ServerWorld)) || world.restoringBlockSnapshots) return false; // retry next cycle + List drops; + final Block block = state.getBlock(); + drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos)); + world.removeBlock(pos, false); + for(ItemStack drop:drops) spawnBlockAsEntity(world, pos, drop); + SoundType stype = state.getBlock().getSoundType(state, world, pos, null); + if(stype != null) world.playSound(null, pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); + return true; + } + + @Override + @SuppressWarnings("deprecation") + public void tick() + { + if(--tick_timer_ > 0) return; + final BlockState device_state = world.getBlockState(pos); + if(!(device_state.getBlock() instanceof BreakerBlock)) return; + if(world.isRemote) { + if(!device_state.get(BreakerBlock.ACTIVE)) { + tick_timer_ = TICK_INTERVAL; + } else { + tick_timer_ = 1; + // not sure if is so cool to do this each tick ... may be simplified/removed again. + SoundEvent sound = SoundEvents.BLOCK_WOOD_HIT; + BlockState target_state = world.getBlockState(pos.offset(device_state.get(BreakerBlock.HORIZONTAL_FACING))); + SoundType stype = target_state.getBlock().getSoundType(target_state); + if((stype == SoundType.CLOTH) || (stype == SoundType.PLANT) || (stype == SoundType.SNOW)) { + sound = SoundEvents.BLOCK_WOOL_HIT; + } else if((stype == SoundType.GROUND) || (stype == SoundType.SAND)) { + sound = SoundEvents.BLOCK_GRAVEL_HIT; + } + world.playSound(pos.getX(), pos.getY(), pos.getZ(), sound, SoundCategory.BLOCKS, 0.1f, 1.2f, false); + } + } else { + tick_timer_ = TICK_INTERVAL; + final BlockPos target_pos = pos.offset(device_state.get(BreakerBlock.HORIZONTAL_FACING)); + final BlockState target_state = world.getBlockState(target_pos); + if((world.isBlockPowered(pos)) || (!isBreakable(target_state, target_pos, world))) { + if(device_state.get(BreakerBlock.ACTIVE)) world.setBlockState(pos, device_state.with(BreakerBlock.ACTIVE, false), 1|2); + proc_time_elapsed_ = 0; + tick_timer_ = IDLE_TICK_INTERVAL; + return; + } + time_needed_ = MathHelper.clamp((int)(target_state.getBlockHardness(world, pos) * breaking_reluctance) + min_breaking_time, min_breaking_time, MAX_BREAKING_TIME); + if(energy_ >= boost_energy_consumption) { + energy_ -= boost_energy_consumption; + proc_time_elapsed_ += TICK_INTERVAL * (1+BOOST_FACTOR); + time_needed_ += min_breaking_time * (3*BOOST_FACTOR/5); + active_timer_ = 2; + } else if(!requires_power) { + proc_time_elapsed_ += TICK_INTERVAL; + active_timer_ = 1024; + } else if(active_timer_ > 0) { + --active_timer_; + } + boolean active = (active_timer_ > 0); + if(requires_power && !active) { + proc_time_elapsed_ = Math.max(0, proc_time_elapsed_ - 2*TICK_INTERVAL); + } + if(proc_time_elapsed_ >= time_needed_) { + proc_time_elapsed_ = 0; + breakBlock(target_state, target_pos, world); + active = false; + } + if(device_state.get(BreakerBlock.ACTIVE) != active) { + world.setBlockState(pos, device_state.with(BreakerBlock.ACTIVE, active), 1|2); + } + } + } + } +} diff --git a/src/main/java/wile/engineersdecor/blocks/EdChair.java b/src/main/java/wile/engineersdecor/blocks/EdChair.java new file mode 100644 index 0000000..42ccdfe --- /dev/null +++ b/src/main/java/wile/engineersdecor/blocks/EdChair.java @@ -0,0 +1,192 @@ +/* + * @file EdChair.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Full block characteristics class. + */ +package wile.engineersdecor.blocks; + +import net.minecraft.entity.monster.piglin.PiglinEntity; +import net.minecraft.util.math.vector.Vector3d; +import wile.engineersdecor.ModContent; +import wile.engineersdecor.ModEngineersDecor; +import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.*; +import net.minecraft.entity.monster.*; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.IPacket; +import net.minecraft.util.math.*; +import net.minecraft.util.*; +import net.minecraftforge.fml.network.FMLPlayMessages; +import net.minecraftforge.fml.network.NetworkHooks; +import java.util.List; +import java.util.Random; + + +public class EdChair +{ + private static boolean sitting_enabled = true; + private static double sitting_probability = 0.1; + private static double standup_probability = 0.01; + + public static void on_config(boolean without_sitting, boolean without_mob_sitting, double sitting_probability_percent, double standup_probability_percent) + { + sitting_enabled = (!without_sitting); + sitting_probability = (without_sitting||without_mob_sitting) ? 0.0 : MathHelper.clamp(sitting_probability_percent/100, 0, 0.9); + standup_probability = (without_sitting||without_mob_sitting) ? 1.0 : MathHelper.clamp(standup_probability_percent/100, 1e-6, 1e-2); + ModEngineersDecor.logger().info("Config chairs sit:" + sitting_enabled + ", mob-sit: " + (sitting_probability*100) + "%, stand up: " + (standup_probability)+"%"); + } + + //-------------------------------------------------------------------------------------------------------------------- + // Block + //-------------------------------------------------------------------------------------------------------------------- + + public static class ChairBlock extends DecorBlock.HorizontalWaterLoggable implements IDecorBlock + { + public ChairBlock(long config, Block.Properties builder, final AxisAlignedBB[] unrotatedAABBs) + { super(config, builder.tickRandomly(), unrotatedAABBs); } + + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) + { + if(!sitting_enabled) return ActionResultType.PASS; + if(!world.isRemote) EntityChair.sit(world, player, pos); + return ActionResultType.SUCCESS; + } + + @Override + @SuppressWarnings("deprecation") + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) + { + if(sitting_enabled && (Math.random() < sitting_probability) && (entity instanceof MobEntity)) EntityChair.sit(world, (LivingEntity)entity, pos); + } + + @Override + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random rnd) + { + if((!sitting_enabled) || (sitting_probability < 1e-6)) return; + final List entities = world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(pos).grow(2,1,2).expand(0,1,0), e->true); + if(entities.isEmpty()) return; + int index = rnd.nextInt(entities.size()); + if((index < 0) || (index >= entities.size())) return; + EntityChair.sit(world, entities.get(index), pos); + } + } + + //-------------------------------------------------------------------------------------------------------------------- + // Entity + //-------------------------------------------------------------------------------------------------------------------- + + public static class EntityChair extends Entity + { + public static final double x_offset = 0.5d; + public static final double y_offset = 0.4d; + public static final double z_offset = 0.5d; + private int t_sit = 0; + public BlockPos chair_pos = new BlockPos(0,0,0); + + public EntityChair(EntityType entityType, World world) + { + super(entityType, world); + preventEntitySpawning=true; + setMotion(Vector3d.ZERO); + canUpdate(true); + noClip=true; + } + + public EntityChair(World world) + { this(ModContent.ET_CHAIR, world); } + + public static EntityChair customClientFactory(FMLPlayMessages.SpawnEntity spkt, World world) + { return new EntityChair(world); } + + public IPacket createSpawnPacket() + { return NetworkHooks.getEntitySpawningPacket(this); } + + public static boolean accepts_mob(LivingEntity entity) + { + if(!(entity instanceof net.minecraft.entity.monster.MonsterEntity)) return false; + if((entity.getType().getSize().height > 2.5) || (entity.getType().getSize().height > 2.0)) return false; + if(entity instanceof ZombieEntity) return true; + if(entity instanceof ZombieVillagerEntity) return true; + if(entity instanceof ZombifiedPiglinEntity) return true; + if(entity instanceof PiglinEntity) return true; + if(entity instanceof HuskEntity) return true; + if(entity instanceof StrayEntity) return true; + if(entity instanceof SkeletonEntity) return true; + if(entity instanceof WitherSkeletonEntity) return true; + return false; + } + + public static void sit(World world, LivingEntity sitter, BlockPos pos) + { + if(!sitting_enabled) return; + if((world==null) || (world.isRemote) || (sitter==null) || (pos==null)) return; + if((!(sitter instanceof PlayerEntity)) && (!accepts_mob(sitter))) return; + if(!world.getEntitiesWithinAABB(EntityChair.class, new AxisAlignedBB(pos)).isEmpty()) return; + if(sitter.isBeingRidden() || (!sitter.isAlive()) || (sitter.isPassenger()) ) return; + if((!world.isAirBlock(pos.up())) || (!world.isAirBlock(pos.up(2)))) return; + boolean on_top_of_block_position = true; + boolean use_next_negative_y_position = false; + EntityChair chair = new EntityChair(world); + BlockPos chair_pos = chair.func_233580_cy_(); + chair.chair_pos = pos; + chair.t_sit = 5; + chair.prevPosX = chair_pos.getX(); + chair.prevPosY = chair_pos.getY(); + chair.prevPosZ = chair_pos.getZ(); + chair.setPosition(pos.getX()+x_offset,pos.getY()+y_offset,pos.getZ()+z_offset); + world.addEntity(chair); + sitter.startRiding(chair, true); + } + + @Override + protected void registerData() {} + + @Override + protected void readAdditional(CompoundNBT compound) {} + + @Override + protected void writeAdditional(CompoundNBT compound) {} + + @Override + public boolean canBePushed() + { return false; } + + @Override + public double getMountedYOffset() + { return 0.0; } + + @Override + public void tick() + { + if(world.isRemote) return; + super.tick(); + if(--t_sit > 0) return; + Entity sitter = getPassengers().isEmpty() ? null : getPassengers().get(0); + if((sitter==null) || (!sitter.isAlive())) { + this.remove(); + return; + } + boolean abort = (!sitting_enabled); + final BlockState state = world.getBlockState(chair_pos); + if((state==null) || (!(state.getBlock() instanceof ChairBlock))) abort = true; + if(!world.isAirBlock(chair_pos.up())) abort = true; + if((!(sitter instanceof PlayerEntity)) && (Math.random() < standup_probability)) abort = true; + if(abort) { + for(Entity e:getPassengers()) { + if(e.isAlive()) e.stopRiding(); + } + this.remove(); + } + } + } + +} diff --git a/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java new file mode 100644 index 0000000..d99e74b --- /dev/null +++ b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java @@ -0,0 +1,1609 @@ +/* + * @file EdCraftingTable.java + * @author Stefan Wilhelm (wile) + * @copyright (C) 2019 Stefan Wilhelm + * @license MIT (see https://opensource.org/licenses/MIT) + * + * Crafting table + */ +package wile.engineersdecor.blocks; + +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.renderer.ItemRenderer; +import wile.engineersdecor.ModContent; +import wile.engineersdecor.ModEngineersDecor; +import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Inventories; +import wile.engineersdecor.libmc.detail.Inventories.SlotRange; +import wile.engineersdecor.libmc.detail.Networking; +import net.minecraft.inventory.container.*; +import net.minecraft.network.play.server.SSetSlotPacket; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SUpdateTileEntityPacket; +import net.minecraft.world.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.Item; +import net.minecraft.item.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.*; +import net.minecraft.inventory.*; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screen.inventory.ContainerScreen; +import net.minecraft.client.gui.widget.button.ImageButton; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import com.mojang.blaze3d.systems.RenderSystem; +import com.google.common.collect.ImmutableList; +import wile.engineersdecor.libmc.detail.TooltipDisplay; +import wile.engineersdecor.libmc.detail.TooltipDisplay.TipRange; + +import javax.annotation.Nullable; +import java.util.*; +import java.util.stream.Collectors; +import java.util.Arrays; + + +public class EdCraftingTable +{ + public static boolean with_assist = true; + public static boolean with_assist_direct_history_refab = false; + public static boolean with_crafting_slot_mouse_scrolling = true; + public static boolean with_outslot_defined_refab = true; + + public static final void on_config(boolean without_crafting_assist, boolean with_assist_immediate_history_refab, + boolean without_crafting_slot_mouse_scrolling) + { + with_assist = !without_crafting_assist; + with_assist_direct_history_refab = with_assist_immediate_history_refab; + with_crafting_slot_mouse_scrolling = !without_crafting_slot_mouse_scrolling; + with_outslot_defined_refab = with_assist; + CraftingHistory.max_history_size(32); + } + + //-------------------------------------------------------------------------------------------------------------------- + // Block + //-------------------------------------------------------------------------------------------------------------------- + + public static final class CraftingTableBlock extends DecorBlock.HorizontalWaterLoggable implements IDecorBlock + { + public CraftingTableBlock(long config, Block.Properties builder, final AxisAlignedBB[] unrotatedAABBs) + { super(config, builder, unrotatedAABBs); } + + @Override + public boolean hasTileEntity(BlockState state) + { return true; } + + @Override + @Nullable + public TileEntity createTileEntity(BlockState state, IBlockReader world) + { return new EdCraftingTable.CraftingTableTileEntity(); } + + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) + { + if(world.isRemote) return ActionResultType.SUCCESS; + final TileEntity te = world.getTileEntity(pos); + if(!(te instanceof CraftingTableTileEntity)) return ActionResultType.FAIL; + if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; + NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); + return ActionResultType.SUCCESS; + } + + @Override + public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) + { + if(world.isRemote) return; + if(!stack.hasTag()) return; + if((!stack.hasTag()) || (!stack.getTag().contains("inventory"))) return; + CompoundNBT inventory_nbt = stack.getTag().getCompound("inventory"); + if(inventory_nbt.isEmpty()) return; + final TileEntity te = world.getTileEntity(pos); + if(!(te instanceof CraftingTableTileEntity)) return; + ((CraftingTableTileEntity)te).readnbt(inventory_nbt); + ((CraftingTableTileEntity)te).markDirty(); + } + + @Override + public boolean hasDynamicDropList() + { return true; } + + @Override + public List dropList(BlockState state, World world, BlockPos pos, final TileEntity te, boolean explosion) + { + final List stacks = new ArrayList(); + if(world.isRemote) return stacks; + if(!(te instanceof CraftingTableTileEntity)) return stacks; + if(!explosion) { + ItemStack stack = new ItemStack(this, 1); + CompoundNBT inventory_nbt = new CompoundNBT(); + ItemStackHelper.saveAllItems(inventory_nbt, ((CraftingTableTileEntity)te).stacks, false); + if(!inventory_nbt.isEmpty()) { + CompoundNBT nbt = new CompoundNBT(); + nbt.put("inventory", inventory_nbt); + stack.setTag(nbt); + } + ((CraftingTableTileEntity) te).clear(); + stacks.add(stack); + } else { + for(ItemStack stack: ((CraftingTableTileEntity)te).stacks) { + if(!stack.isEmpty()) stacks.add(stack); + } + ((CraftingTableTileEntity)te).reset(); + } + return stacks; + } + } + + //-------------------------------------------------------------------------------------------------------------------- + // Tile entity + //-------------------------------------------------------------------------------------------------------------------- + + public static class CraftingTableTileEntity extends TileEntity implements IInventory, INameable, INamedContainerProvider + { + public static final int NUM_OF_SLOTS = 9+18; + protected NonNullList stacks = NonNullList.withSize(NUM_OF_SLOTS, ItemStack.EMPTY); + protected CompoundNBT history = new CompoundNBT(); + + public CraftingTableTileEntity() + { this(ModContent.TET_CRAFTING_TABLE); } + + public CraftingTableTileEntity(TileEntityType te_type) + { super(te_type); } + + public void reset() + { stacks = NonNullList.withSize(NUM_OF_SLOTS, ItemStack.EMPTY); } + + public void readnbt(CompoundNBT nbt) + { + reset(); + ItemStackHelper.loadAllItems(nbt, this.stacks); + while(this.stacks.size() < NUM_OF_SLOTS) this.stacks.add(ItemStack.EMPTY); + history = nbt.getCompound("history"); + } + + private void writenbt(CompoundNBT nbt) + { + ItemStackHelper.saveAllItems(nbt, this.stacks); + if(!history.isEmpty()) nbt.put("history", history); + } + + // TileEntity ------------------------------------------------------------------------------ + + @Override + public void func_230337_a_(BlockState state, CompoundNBT nbt) + { super.func_230337_a_(state, nbt); readnbt(nbt); } + + @Override + public CompoundNBT write(CompoundNBT nbt) + { super.write(nbt); writenbt(nbt); return nbt; } + + @Override + public CompoundNBT getUpdateTag() + { CompoundNBT nbt = super.getUpdateTag(); writenbt(nbt); return nbt; } + + @Override + @Nullable + public SUpdateTileEntityPacket getUpdatePacket() + { return new SUpdateTileEntityPacket(pos, 1, getUpdateTag()); } + + @Override + public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) // on client + { + //@todo: check if that is still needed: super.read(pkt.getNbtCompound()); + readnbt(pkt.getNbtCompound()); + super.onDataPacket(net, pkt); + } + + @Override + public void handleUpdateTag(BlockState state, CompoundNBT tag) // on client + { func_230337_a_/*read*/(state, tag); } + + @OnlyIn(Dist.CLIENT) + public double getMaxRenderDistanceSquared() + { return 400; } + + // INameable --------------------------------------------------------------------------- + + @Override + public ITextComponent getName() + { final Block block=getBlockState().getBlock(); return new StringTextComponent((block!=null) ? block.getTranslationKey() : "Treated wood crafting table"); } + + @Override + public boolean hasCustomName() + { return false; } + + @Override + public ITextComponent getCustomName() + { return getName(); } + + // INamedContainerProvider ------------------------------------------------------------------------------ + + @Override + public ITextComponent getDisplayName() + { return INameable.super.getDisplayName(); } + + @Override + public Container createMenu( int id, PlayerInventory inventory, PlayerEntity player ) + { return new CraftingTableContainer(id, inventory, this, IWorldPosCallable.of(world, pos)); } + + // IInventory ------------------------------------------------------------------------------ + + @Override + public int getSizeInventory() + { return stacks.size(); } + + @Override + public boolean isEmpty() + { for(ItemStack stack: stacks) { if(!stack.isEmpty()) return false; } return true; } + + @Override + public ItemStack getStackInSlot(int index) + { return (index < getSizeInventory()) ? stacks.get(index) : ItemStack.EMPTY; } + + @Override + public ItemStack decrStackSize(int index, int count) + { return ItemStackHelper.getAndSplit(stacks, index, count); } + + @Override + public ItemStack removeStackFromSlot(int index) + { return ItemStackHelper.getAndRemove(stacks, index); } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) + { stacks.set(index, stack); } + + @Override + public int getInventoryStackLimit() + { return 64; } + + @Override + public void markDirty() + { super.markDirty(); } + + @Override + public boolean isUsableByPlayer(PlayerEntity player) + { return getPos().distanceSq(player.func_233580_cy_()) < 36; } + + @Override + public void openInventory(PlayerEntity player) + {} + + @Override + public void closeInventory(PlayerEntity player) + { + markDirty(); + if(world instanceof World) { + BlockState state = world.getBlockState(pos); + world.notifyBlockUpdate(pos, state, state, 1|2); + } + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) + { return true; } + + @Override + public void clear() + { stacks.clear(); } + + } + + //-------------------------------------------------------------------------------------------------------------------- + // Crafting container + //-------------------------------------------------------------------------------------------------------------------- + + public static class CraftingTableContainer extends Container implements Networking.INetworkSynchronisableContainer + { + protected static final String BUTTON_NEXT = "next"; + protected static final String BUTTON_PREV = "prev"; + protected static final String BUTTON_CLEAR_GRID = "clear"; + protected static final String BUTTON_NEXT_COLLISION_RECIPE = "next-recipe"; + protected static final String ACTION_PLACE_CURRENT_HISTORY_SEL = "place-refab"; + protected static final String ACTION_PLACE_SHIFTCLICKED_STACK = "place-stack"; + protected static final String ACTION_MOVE_ALL_STACKS = "move-stacks"; + protected static final String ACTION_INCREASE_CRAFTING_STACKS = "inc-crafting-stacks"; + protected static final String ACTION_DECREASE_CRAFTING_STACKS = "dec-crafting-stacks"; + + public static final int CRAFTING_SLOTS_BEGIN = 0; + public static final int NUM_OF_CRAFTING_SLOTS = 9; + public static final int STORAGE_SLOTS_BEGIN = NUM_OF_CRAFTING_SLOTS; + public static final int NUM_OF_STORAGE_SLOTS = CraftingTableTileEntity.NUM_OF_SLOTS - NUM_OF_CRAFTING_SLOTS; + + public final ImmutableList> CRAFTING_SLOT_COORDINATES; + private final PlayerEntity player_; + private final IInventory inventory_; + private final IWorldPosCallable wpc_; + private final CraftingHistory history_; + private final CraftingTableGrid matrix_; + private final CraftResultInventory result_; + private boolean has_recipe_collision_; + private boolean crafting_matrix_changed_now_; + + public CraftingTableContainer(int cid, PlayerInventory pinv) + { this(cid, pinv, new Inventory(CraftingTableTileEntity.NUM_OF_SLOTS), IWorldPosCallable.DUMMY); } + + private CraftingTableContainer(int cid, PlayerInventory pinv, IInventory block_inventory, IWorldPosCallable wpc) + { + super(ModContent.CT_TREATED_WOOD_CRAFTING_TABLE, cid); + wpc_ = wpc; + player_ = pinv.player; + inventory_ = block_inventory; + World world = player_.world; + if(world.isRemote && (inventory_ instanceof CraftingTableTileEntity)) world = ((CraftingTableTileEntity)inventory_).getWorld(); + history_ = new CraftingHistory(world); + result_ = new CraftResultInventory(); + matrix_ = new CraftingTableGrid(this, block_inventory); + matrix_.openInventory(player_); + // container slotId 0 === crafting output + addSlot(new CraftingOutputSlot(this, pinv.player, matrix_, result_, 0, 118, 27)); + ArrayList> slotpositions = new ArrayList>(); + slotpositions.add(new Tuple<>(118, 27)); + // container slotId 1..9 === TE slots 0..8 + for(int y=0; y<3; ++y) { + for(int x=0; x<3; ++x) { + int xpos = 44+x*18; + int ypos = 9+y*18; + addSlot(new CraftingGridSlot(matrix_, x+y*3, xpos, ypos)); + slotpositions.add(new Tuple<>(xpos, ypos)); + } + } + // container slotId 10..36 === player slots: 9..35 + for(int y=0; y<3; ++y) { + for(int x=0; x<9; ++x) { + addSlot(new Slot(pinv, x+y*9+9, 8+x*18, 110+y*18)); + } + } + // container slotId 37..45 === player slots: 0..8 + for(int x=0; x<9; ++x) { + addSlot(new Slot(pinv, x, 8+x*18, 168)); + } + // container slotId 46..53 === TE slots 9..17 (storage) + for(int y=0; y<2; ++y) { + for(int x=0; x<9; ++x) { + addSlot(new Slot(matrix_, 9+x+y*9, 8+x*18, 65+y*18)); + } + } + if((!player_.world.isRemote) && (inventory_ instanceof CraftingTableTileEntity)) { + history_.read(((CraftingTableTileEntity)inventory_).history.copy()); + syncHistory(); + } + CRAFTING_SLOT_COORDINATES = ImmutableList.copyOf(slotpositions); + onCraftMatrixChanged(matrix_); + } + + @Override + public boolean canInteractWith(PlayerEntity player) + { return inventory_.isUsableByPlayer(player); } + + @Override + public void onCraftMatrixChanged(IInventory inv) + { + detectAndSendChanges(); + wpc_.consume((world,pos)->{ + if(world.isRemote) return; + try { + crafting_matrix_changed_now_ = true; + ServerPlayerEntity player = (ServerPlayerEntity) player_; + ItemStack stack = ItemStack.EMPTY; + List recipes = world.getServer().getRecipeManager().getRecipes(IRecipeType.CRAFTING, matrix_, world); + has_recipe_collision_ = false; + if(recipes.size() > 0) { + ICraftingRecipe recipe = recipes.get(0); + IRecipe currently_used = result_.getRecipeUsed(); + has_recipe_collision_ = (recipes.size() > 1); + if((recipes.size() > 1) && (currently_used instanceof ICraftingRecipe) && (recipes.contains(currently_used))) { + recipe = (ICraftingRecipe)currently_used; + } + if(result_.canUseRecipe(world, player, recipe)) { + stack = recipe.getCraftingResult(matrix_); + } + } + result_.setInventorySlotContents(0, stack); + player.connection.sendPacket(new SSetSlotPacket(windowId, 0, stack)); + syncProperties(); + } catch(Throwable exc) { + ModEngineersDecor.logger().error("Recipe failed:", exc); + } + }); + } + + @Override + public void onContainerClosed(PlayerEntity player) + { + matrix_.closeInventory(player); + result_.clear(); + result_.closeInventory(player); + if(player!=null) { + for(Slot e:player.container.inventorySlots) { + if(e instanceof CraftingResultSlot) { + ((CraftingResultSlot)e).putStack(ItemStack.EMPTY); + } + } + } + } + + @Override + public boolean canMergeSlot(ItemStack stack, Slot slot) + { return (slot.inventory != result_) && (super.canMergeSlot(stack, slot)); } + + @Override + public ItemStack transferStackInSlot(PlayerEntity player, int index) + { + Slot slot = inventorySlots.get(index); + if((slot == null) || (!slot.getHasStack())) return ItemStack.EMPTY; + ItemStack slotstack = slot.getStack(); + ItemStack stack = slotstack.copy(); + if(index == 0) { + wpc_.consume((world, pos)->slotstack.getItem().onCreated(slotstack, world, player)); + if(!this.mergeItemStack(slotstack, 10, 46, true)) return ItemStack.EMPTY; + slot.onSlotChange(slotstack, stack); + } else if(index >= 10 && (index < 46)) { + if(!this.mergeItemStack(slotstack, 46, 54, false)) return ItemStack.EMPTY; + } else if((index >= 46) && (index < 54)) { + if(!this.mergeItemStack(slotstack, 10, 46, false)) return ItemStack.EMPTY; + } else if(!this.mergeItemStack(slotstack, 10, 46, false)) { + return ItemStack.EMPTY; + } + if(slotstack.isEmpty()) { + slot.putStack(ItemStack.EMPTY); + } else { + slot.onSlotChanged(); + } + if(slotstack.getCount() == stack.getCount()) { + return ItemStack.EMPTY; + } + ItemStack itemstack2 = slot.onTake(player, slotstack); + if(index == 0) { + player.dropItem(itemstack2, false); + } + return stack; + } + + @Override + public ItemStack slotClick(int slotId, int button, ClickType clickType, PlayerEntity player) + { + crafting_matrix_changed_now_ = false; + final ItemStack stack = super.slotClick(slotId, button, clickType, player); + if((with_outslot_defined_refab) && (slotId == 0) && (clickType == ClickType.PICKUP)) { + if((!crafting_matrix_changed_now_) && (!player.world.isRemote()) && (crafting_grid_empty())) { + final ItemStack dragged = player.inventory.getItemStack(); + if((dragged != null) && (!dragged.isEmpty())) { + try_result_stack_refab(dragged, player.world); + } else if(!history().current().isEmpty()) { + try_result_stack_refab(history().current_recipe().getRecipeOutput(), player.world); + } + } + } + return stack; + } + + // Container client/server synchronisation -------------------------------------------------- + + @OnlyIn(Dist.CLIENT) + public void onGuiAction(String message, CompoundNBT nbt) + { + nbt.putString("action", message); + Networking.PacketContainerSyncClientToServer.sendToServer(windowId, nbt); + } + + @Override + public void onServerPacketReceived(int windowId, CompoundNBT nbt) + { + if(nbt.contains("history")) history_.read(nbt.getCompound("history")); + if(nbt.contains("hascollision")) has_recipe_collision_ = nbt.getBoolean("hascollision"); + } + + @Override + public void onClientPacketReceived(int windowId, PlayerEntity player, CompoundNBT nbt) + { + boolean changed = false; + boolean player_inventory_changed = false; + if(with_assist && nbt.contains("action")) { + switch(nbt.getString("action")) { + case BUTTON_NEXT: { + history_.next(); + syncHistory(); + // implicitly clear the grid, so that the player can see the refab, and that no recipe is active. + if(clear_grid_to_player(player)) { changed = true; player_inventory_changed = true; } + if(clear_grid_to_storage(player)) changed = true; + } break; + case BUTTON_PREV: { + history_.prev(); + syncHistory(); + if(clear_grid_to_player(player)) { changed = true; player_inventory_changed = true; } + if(clear_grid_to_storage(player)) changed = true; + } break; + case BUTTON_CLEAR_GRID: { + history_.reset_selection(); + syncHistory(); + if(clear_grid_to_player(player)) { changed = true; player_inventory_changed = true; } + if(clear_grid_to_storage(player)) changed = true; + } break; + case ACTION_PLACE_CURRENT_HISTORY_SEL: { + if(place_stacks(new SlotRange[]{ + new SlotRange(player.inventory, 0, 9), + new SlotRange(player.inventory, 9, 36), + new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS) + }, refab_crafting_stacks()) != PlacementResult.UNCHANGED) { + changed = true; + } + } break; + case ACTION_PLACE_SHIFTCLICKED_STACK: { + final int container_slot_id = nbt.getInt("containerslot"); + if((container_slot_id < 10) || (container_slot_id > 53)) { + break; // out of range + } + if(container_slot_id >= 46) { + // from storage + final int storage_slot = container_slot_id - 46 + STORAGE_SLOTS_BEGIN; + PlacementResult stat = distribute_stack(inventory_, storage_slot); + if(stat != PlacementResult.UNCHANGED) changed = true; + } else { + // from player + int player_slot = (container_slot_id >= 37) ? (container_slot_id-37) : (container_slot_id-10+9); + final ItemStack reference_stack = player.inventory.getStackInSlot(player_slot).copy(); + if((!reference_stack.isEmpty()) && (distribute_stack(player.inventory, player_slot) != PlacementResult.UNCHANGED)) { + player_inventory_changed = true; + changed = true; + if(nbt.contains("move-all")) { + for(int i=0; i < player.inventory.getSizeInventory(); ++i) { + final ItemStack stack = player.inventory.getStackInSlot(i); + if(!Inventories.areItemStacksIdentical(reference_stack, stack)) continue; + if(distribute_stack(player.inventory, i) == PlacementResult.UNCHANGED) break; // grid is full + } + } + } + } + } break; + case ACTION_MOVE_ALL_STACKS: { + final int container_slot_id = nbt.getInt("containerslot"); + if((container_slot_id < 1) || (container_slot_id >= (46+NUM_OF_STORAGE_SLOTS))) { + break; // out of range + } else if(container_slot_id < 10) { + // from crafting grid to player inventory, we clear the grid here as this is most likely + // what is wanted in the end. Saves clicking the other grid stacks. + if(clear_grid_to_player(player)) { changed = true; player_inventory_changed = true; } + if(clear_grid_to_storage(player)) changed = true; + break; + } + IInventory from_inventory; + SlotRange[] to_ranges; + int from_slot; + if(container_slot_id >= 46) { + // from storage to player inventory + from_inventory = inventory_; + from_slot = container_slot_id - 46 + STORAGE_SLOTS_BEGIN; + to_ranges = new SlotRange[] {new SlotRange(player.inventory, 9, 36), new SlotRange(player.inventory, 0, 9)}; + } else { + // from player to storage (otherwise ACTION_PLACE_SHIFTCLICKED_STACK would have been used) + from_inventory = player.inventory; + from_slot = (container_slot_id >= 37) ? (container_slot_id-37) : (container_slot_id-10+9); + to_ranges = new SlotRange[] {new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)}; + } + final ItemStack reference_stack = from_inventory.getStackInSlot(from_slot).copy(); + if(!reference_stack.isEmpty()) { + boolean abort = false; + for(int i=0; (i < from_inventory.getSizeInventory()) && (!abort); ++i) { + final ItemStack stack = from_inventory.getStackInSlot(i); + if(Inventories.areItemStacksDifferent(reference_stack, stack)) continue; + ItemStack remaining = from_inventory.getStackInSlot(i); + for(SlotRange range:to_ranges) { + remaining = range.insert(remaining, false, 0, false, true); + if(!remaining.isEmpty()) { + abort = true; // no space left + break; + } else { + changed = player_inventory_changed = true; + } + } + from_inventory.setInventorySlotContents(i, remaining); + } + } + } break; + case BUTTON_NEXT_COLLISION_RECIPE: { + select_next_collision_recipe(inventory_); + } break; + case ACTION_DECREASE_CRAFTING_STACKS: { + changed = player_inventory_changed = decrease_grid_stacks(new SlotRange[]{ + new SlotRange(player.inventory, 9, 36), + new SlotRange(player.inventory, 0, 9), + new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS) + }, MathHelper.clamp(nbt.getInt("limit"), 1, 8)); + } break; + case ACTION_INCREASE_CRAFTING_STACKS: { + changed = player_inventory_changed = increase_grid_stacks(new SlotRange[]{ + new SlotRange(player.inventory, 9, 36), + new SlotRange(player.inventory, 0, 9), + new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS) + }, MathHelper.clamp(nbt.getInt("limit"), 1, 8)); + } break; + } + } + if(changed) inventory_.markDirty(); + if(player_inventory_changed) player.inventory.markDirty(); + if(changed || player_inventory_changed) { + this.onCraftMatrixChanged(inventory_); + this.detectAndSendChanges(); + } + } + + public CraftingHistory history() + { return history_; } + + private void syncHistory() + { + if(!with_assist) return; + this.wpc_.consume((world,pos)->{ + if(world.isRemote()) return; + CompoundNBT hist_nbt = history_.write(); + if((inventory_ instanceof CraftingTableTileEntity)) { + ((CraftingTableTileEntity)inventory_).history = hist_nbt.copy(); + inventory_.markDirty(); + } + final CompoundNBT nbt = new CompoundNBT(); + nbt.put("history", hist_nbt); + nbt.putBoolean("hascollision", has_recipe_collision_); + Networking.PacketContainerSyncServerToClient.sendToListeners(world, this, nbt); + }); + } + + private void syncProperties() + { + this.wpc_.consume((world,pos)->{ + final CompoundNBT nbt = new CompoundNBT(); + nbt.putBoolean("hascollision", has_recipe_collision_); + Networking.PacketContainerSyncServerToClient.sendToListeners(world, this, nbt); + }); + } + + // private aux methods --------------------------------------------------------------------- + + public boolean has_recipe_collision() + { return has_recipe_collision_; } + + public void select_next_collision_recipe(IInventory inv) + { + wpc_.consume((world,pos)->{ + if(world.isRemote) return; + try { + ServerPlayerEntity player = (ServerPlayerEntity) player_; + final List matching_recipes = world.getServer().getRecipeManager().getRecipes(IRecipeType.CRAFTING, matrix_, world); + if(matching_recipes.size() < 2) return; // nothing to change + IRecipe currently_used = result_.getRecipeUsed(); + List usable_recipes = matching_recipes.stream() + .filter((r)->result_.canUseRecipe(world,player,r)) + .sorted((a,b)->Integer.compare(a.getId().hashCode(), b.getId().hashCode())) + .collect(Collectors.toList()); + for(int i=0; i= usable_recipes.size()) i=0; + currently_used = usable_recipes.get(i); + ItemStack stack = ((ICraftingRecipe)currently_used).getCraftingResult(matrix_); + result_.setInventorySlotContents(0, stack); + result_.setRecipeUsed(currently_used); + break; + } + } + onCraftMatrixChanged(inv); + } catch(Throwable exc) { + ModEngineersDecor.logger().error("Recipe failed:", exc); + } + }); + } + + @Nullable + private ICraftingRecipe find_first_recipe_for(World world, ItemStack stack) + { + return (ICraftingRecipe)world.getServer().getRecipeManager().getRecipes().stream() + .filter(r->(r.getType()==IRecipeType.CRAFTING) && (r.getRecipeOutput().isItemEqual(stack))) + .findFirst().orElse(null); + } + + private ItemStack search_inventory(ItemStack match_stack, ItemStack not_found_value) { + SlotRange search_ranges[] = new SlotRange[]{ + new SlotRange(player_.inventory, 0, 36), + new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS) + }; + for(SlotRange range: search_ranges) { + for(int i=0; i placement_stacks(ICraftingRecipe recipe) + { + final World world = player_.world; + final ArrayList grid = new ArrayList(); + if(recipe.getIngredients().size() > 9) { + return grid; + } else if(recipe instanceof ShapedRecipe) { + final int endw = ((ShapedRecipe)recipe).getWidth(); + final int endh = ((ShapedRecipe)recipe).getHeight(); + int ingredient_index = 0; + for(int i=3-endh; i>0; --i) for(int w=0; w<3; ++w) { + grid.add(ItemStack.EMPTY); + } + for(int h=3-endh; h<3; ++h) for(int w=0; w<3; ++w) { + if((w >= endw) || (ingredient_index >= recipe.getIngredients().size())) { grid.add(ItemStack.EMPTY); continue; } + ItemStack[] match_stacks = recipe.getIngredients().get(ingredient_index++).getMatchingStacks(); + if(match_stacks.length == 0) { grid.add(ItemStack.EMPTY); continue; } + ItemStack preferred = search_inventory(match_stacks, match_stacks[0]); + if(preferred.isEmpty()) { grid.add(ItemStack.EMPTY); continue; } + grid.add(preferred); + } + } else if(recipe instanceof ShapelessRecipe) { + // todo: check if a collision resolver with shaped recipes makes sense here. + for(int ingredient_index=0; ingredient_index grid_stacks) + { + boolean changed = false; + final List ingredients = recipe.getIngredients(); + for(int stack_index=0; stack_index < grid_stacks.size(); ++stack_index) { + ItemStack to_replace = grid_stacks.get(stack_index); + ItemStack replacement = to_replace; + if(to_replace.isEmpty() || (!search_inventory(to_replace, ItemStack.EMPTY).isEmpty())) continue; // no replacement needed + for(int ingredient_index=0; ingredient_indexInventories.areItemStacksIdentical(s, to_replace))) { + replacement = search_inventory(match_stacks, to_replace); + changed = true; + break; + } + } + grid_stacks.set(stack_index, replacement); + } + return changed; + } + + private void try_result_stack_refab(ItemStack output_stack, World world) + { + ICraftingRecipe recipe; + int history_index = history().find(output_stack); + if(history_index >= 0) { + history().selection(history_index); + recipe = history().current_recipe(); + List grid_stacks = history().current().subList(1, history().current().size()); + if(adapt_recipe_placement(recipe, grid_stacks)) { + history().stash(grid_stacks, recipe); + recipe = history().current_recipe(); + } + } else if((recipe=find_first_recipe_for(world, output_stack)) != null) { + ArrayList stacks = placement_stacks(recipe); + if(stacks.isEmpty()) { + recipe = null; + } else { + history().stash(stacks, recipe); + recipe = history().current_recipe(); + } + } + if(recipe != null) { + onCraftMatrixChanged(inventory_); + syncHistory(); + } + } + + private boolean crafting_grid_empty() + { for(int i=0; i<10; ++i) { if(getSlot(i).getHasStack()) return false; } return true; } + + private boolean itemstack_recipe_match(ItemStack grid_stack, ItemStack history_stack) + { + if(history_.current_recipe()!=null) { + final NonNullList ingredients = history_.current_recipe().getIngredients(); + boolean grid_match, dist_match; + for(int i=0; i refab_crafting_stacks() + { + final ArrayList slots = new ArrayList(); + final List tocraft = history_.current(); + final int stack_sizes[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1}; + if(tocraft.isEmpty()) return slots; + for(int i=0; i<9; ++i) { + if((i+CraftingHistory.INPUT_STACKS_BEGIN) >= tocraft.size()) break; + final ItemStack needed = tocraft.get(i+CraftingHistory.INPUT_STACKS_BEGIN); + final ItemStack palced = inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN); + if(needed.isEmpty() && (!palced.isEmpty())) return slots; // history vs grid mismatch. + if((!palced.isEmpty()) && (!itemstack_recipe_match(needed, palced))) return slots; // also mismatch + if(!needed.isEmpty()) stack_sizes[i] = palced.getCount(); + } + int min_placed = 64, max_placed=0; + for(int i=0; i<9; ++i) { + if(stack_sizes[i] < 0) continue; + min_placed = Math.min(min_placed, stack_sizes[i]); + max_placed = Math.max(max_placed, stack_sizes[i]); + } + int fillup_size = (max_placed <= min_placed) ? (min_placed + 1) : max_placed; + for(int i=0; i<9; ++i) { + if(stack_sizes[i] < 0) continue; + if(fillup_size > inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN).getMaxStackSize()) return slots; // can't fillup all + } + for(int i=0; i<9; ++i) { + if(stack_sizes[i] < 0) { + slots.add(ItemStack.EMPTY); + } else { + ItemStack st = inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN).copy(); + if(st.isEmpty()) { + st = tocraft.get(i+CraftingHistory.INPUT_STACKS_BEGIN).copy(); + st.setCount(Math.min(st.getMaxStackSize(), fillup_size)); + } else { + st.setCount(MathHelper.clamp(fillup_size-st.getCount(), 0, st.getMaxStackSize())); + } + slots.add(st); + } + } + return slots; + } + + private List incr_crafting_grid_stacks(int count) + { + final ArrayList stacks = new ArrayList(); + for(int i=0; i<9; ++i) { + final ItemStack palced = inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN).copy(); + if(!palced.isEmpty()) palced.setCount(count); + stacks.add(palced); + } + return stacks; + } + + private boolean clear_grid_to_storage(PlayerEntity player) + { + boolean changed = false; + for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN+NUM_OF_CRAFTING_SLOTS); ++grid_i) { + ItemStack stack = inventory_.getStackInSlot(grid_i); + if(stack.isEmpty()) continue; + ItemStack remaining = (new SlotRange(inventory_, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)).insert(stack, false, 0); + inventory_.setInventorySlotContents(grid_i, remaining); + changed = true; + } + return changed; + } + + private boolean clear_grid_to_player(PlayerEntity player) + { + boolean changed = false; + for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN+NUM_OF_CRAFTING_SLOTS); ++grid_i) { + ItemStack remaining = inventory_.getStackInSlot(grid_i); + if(remaining.isEmpty()) continue; + remaining = (new SlotRange(player.inventory,9, 36)).insert(remaining,true, 0); // prefer filling up inventory stacks + remaining = (new SlotRange(player.inventory,0, 9)).insert(remaining, true, 0); // then fill up the hotbar stacks + remaining = (new SlotRange(player.inventory,9, 36)).insert(remaining, false, 0); // then allow empty stacks in inventory + remaining = (new SlotRange(player.inventory,0, 9)).insert(remaining, false, 0); // then new stacks in the hotbar + inventory_.setInventorySlotContents(grid_i, remaining); + changed = true; + } + return changed; + } + + private PlacementResult place_stacks(final SlotRange[] ranges, final List to_fill) + { + if(history_.current_recipe() != null) result_.setRecipeUsed(history_.current_recipe()); + boolean slots_changed = false; + if(!to_fill.isEmpty()) { + for(SlotRange slot_range: ranges) { + for(int it_guard=63; it_guard>=0; --it_guard) { + boolean slots_updated = false; + for(int i = 0; i < 9; ++i) { + if(to_fill.get(i).isEmpty()) continue; + ItemStack grid_stack = inventory_.getStackInSlot(i + CRAFTING_SLOTS_BEGIN).copy(); + if(grid_stack.getCount() >= grid_stack.getMaxStackSize()) continue; + final ItemStack req_stack = to_fill.get(i).copy(); + req_stack.setCount(1); + final ItemStack mv_stack = slot_range.extract(req_stack); + if(mv_stack.isEmpty()) continue; + to_fill.get(i).shrink(1); + if(grid_stack.isEmpty()) { + grid_stack = mv_stack.copy(); + } else { + grid_stack.grow(mv_stack.getCount()); + } + inventory_.setInventorySlotContents(i + CRAFTING_SLOTS_BEGIN, grid_stack); + slots_changed = true; + slots_updated = true; + } + if(!slots_updated) break; + } + } + } + boolean missing_item = false; + for(ItemStack st:to_fill) { + if(!st.isEmpty()) { + missing_item = true; + break; + } + } + if(!slots_changed) { + return PlacementResult.UNCHANGED; + } else if(missing_item) { + return PlacementResult.INCOMPLETE; + } else { + return PlacementResult.PLACED; + } + } + + private PlacementResult distribute_stack(IInventory inventory, final int slotno) + { + List to_refab = refab_crafting_stacks(); + if(history_.current_recipe() != null) result_.setRecipeUsed(history_.current_recipe()); + ItemStack to_distribute = inventory.getStackInSlot(slotno).copy(); + if(to_distribute.isEmpty()) return PlacementResult.UNCHANGED; + int matching_grid_stack_sizes[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1}; + int max_matching_stack_size = -1; + int min_matching_stack_size = 65; + int total_num_missing_stacks = 0; + for(int i=0; i<9; ++i) { + final ItemStack grid_stack = inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN); + final ItemStack refab_stack = to_refab.isEmpty() ? ItemStack.EMPTY : to_refab.get(i).copy(); + if((!grid_stack.isEmpty()) && Inventories.areItemStacksIdentical(grid_stack, to_distribute)) { + matching_grid_stack_sizes[i] = grid_stack.getCount(); + total_num_missing_stacks += grid_stack.getMaxStackSize()-grid_stack.getCount(); + if(max_matching_stack_size < matching_grid_stack_sizes[i]) max_matching_stack_size = matching_grid_stack_sizes[i]; + if(min_matching_stack_size > matching_grid_stack_sizes[i]) min_matching_stack_size = matching_grid_stack_sizes[i]; + } else if((!refab_stack.isEmpty()) && (Inventories.areItemStacksIdentical(refab_stack, to_distribute))) { + matching_grid_stack_sizes[i] = 0; + total_num_missing_stacks += grid_stack.getMaxStackSize(); + if(max_matching_stack_size < matching_grid_stack_sizes[i]) max_matching_stack_size = matching_grid_stack_sizes[i]; + if(min_matching_stack_size > matching_grid_stack_sizes[i]) min_matching_stack_size = matching_grid_stack_sizes[i]; + } else if(grid_stack.isEmpty() && (!refab_stack.isEmpty())) { + if(itemstack_recipe_match(to_distribute, refab_stack)) { + matching_grid_stack_sizes[i] = 0; + total_num_missing_stacks += grid_stack.getMaxStackSize(); + if(max_matching_stack_size < matching_grid_stack_sizes[i]) max_matching_stack_size = matching_grid_stack_sizes[i]; + if(min_matching_stack_size > matching_grid_stack_sizes[i]) min_matching_stack_size = matching_grid_stack_sizes[i]; + } + } + } + if(min_matching_stack_size < 0) return PlacementResult.UNCHANGED; + final int stack_limit_size = Math.min(to_distribute.getMaxStackSize(), inventory_.getInventoryStackLimit()); + if(min_matching_stack_size >= stack_limit_size) return PlacementResult.UNCHANGED; + int n_to_distribute = to_distribute.getCount(); + for(int it_guard=63; it_guard>=0; --it_guard) { + if(n_to_distribute <= 0) break; + for(int i=0; i<9; ++i) { + if(n_to_distribute <= 0) break; + if(matching_grid_stack_sizes[i] == min_matching_stack_size) { + ++matching_grid_stack_sizes[i]; + --n_to_distribute; + } + } + if(min_matching_stack_size < max_matching_stack_size) { + ++min_matching_stack_size; // distribute short stacks + } else { + ++min_matching_stack_size; // stacks even, increase all + max_matching_stack_size = min_matching_stack_size; + } + if(min_matching_stack_size >= stack_limit_size) break; // all full + } + if(n_to_distribute == to_distribute.getCount()) return PlacementResult.UNCHANGED; // was already full + if(n_to_distribute <= 0) { + inventory.setInventorySlotContents(slotno, ItemStack.EMPTY); + } else { + to_distribute.setCount(n_to_distribute); + inventory.setInventorySlotContents(slotno, to_distribute); + } + for(int i=0; i<9; ++i) { + if(matching_grid_stack_sizes[i] < 0) continue; + ItemStack grid_stack = inventory_.getStackInSlot(i + CRAFTING_SLOTS_BEGIN).copy(); + if(grid_stack.isEmpty()) grid_stack = to_distribute.copy(); + grid_stack.setCount(matching_grid_stack_sizes[i]); + inventory_.setInventorySlotContents(i + CRAFTING_SLOTS_BEGIN, grid_stack); + } + return PlacementResult.PLACED; + } + + private boolean decrease_grid_stacks(SlotRange[] ranges, int limit) + { + boolean changed = false; + for(int i=0; i<9; ++i) { + ItemStack stack = inventory_.getStackInSlot(i+CRAFTING_SLOTS_BEGIN).copy(); + if(stack.isEmpty()) continue; + for(SlotRange range:ranges) { + ItemStack remaining = range.insert(stack, false, limit); + if(remaining.getCount() < stack.getCount()) changed = true; + boolean stop = (remaining.getCount() <= Math.max(0, (stack.getCount()-limit))); + stack = remaining; + if(stop) break; + } + inventory_.setInventorySlotContents(i+CRAFTING_SLOTS_BEGIN, stack.isEmpty() ? ItemStack.EMPTY : stack); + } + return changed; + } + + private boolean increase_grid_stacks(SlotRange[] ranges, int limit) + { return place_stacks(ranges, incr_crafting_grid_stacks(limit)) != PlacementResult.UNCHANGED; } + + } + + //-------------------------------------------------------------------------------------------------------------------- + // GUI + //-------------------------------------------------------------------------------------------------------------------- + + @OnlyIn(Dist.CLIENT) + public static class CraftingTableGui extends ContainerScreen + { + protected static final ResourceLocation BACKGROUND = new ResourceLocation(ModEngineersDecor.MODID, "textures/gui/metal_crafting_table_gui.png"); + protected final PlayerEntity player; + protected final ArrayList