mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
725d556718 | ||
|
|
d88c007fbb | ||
|
|
485333c6aa | ||
|
|
240802082e | ||
|
|
6f182e932d | ||
|
|
d08b42f18c | ||
|
|
57cc915a1e | ||
|
|
d7c5940596 | ||
|
|
79a6af701b | ||
|
|
4c0b503b8b | ||
|
|
2a6f3771a3 | ||
|
|
04a7c96b4d | ||
|
|
6d0a001b9e | ||
|
|
e2c2ff8d30 | ||
|
|
586f5bf093 | ||
|
|
755301d313 | ||
|
|
33f3389b84 | ||
|
|
c9167b8316 | ||
|
|
1ed646b147 | ||
|
|
7a7930d7eb | ||
|
|
3dccc7e06d | ||
|
|
18e26956ef | ||
|
|
713b0f9d9e | ||
|
|
c6f2e3c7b3 | ||
|
|
c6d8518d82 | ||
|
|
98711e5d34 | ||
|
|
5caab59507 | ||
|
|
41d47d99ca | ||
|
|
3c6d5d04d0 | ||
|
|
137927b3e6 | ||
|
|
8aa7e05bbe | ||
|
|
16414da3f2 | ||
|
|
11eb4b62df | ||
|
|
a172cb379f | ||
|
|
c979d1fa79 | ||
|
|
ef5825edcf | ||
|
|
9570cb2982 | ||
|
|
f89a074393 | ||
|
|
19457080bf | ||
|
|
d6ec27209b | ||
|
|
a0435886ab | ||
|
|
2ab8613bec | ||
|
|
9d31dedd35 | ||
|
|
2dd539c3df | ||
|
|
fd2ac7d172 | ||
|
|
466110d461 | ||
|
|
ecf0d7165c | ||
|
|
dde3514dce | ||
|
|
0f24a4e043 | ||
|
|
3ed2ecfdd0 | ||
|
|
be548b06cc | ||
|
|
7db0dc7767 | ||
|
|
2e20b14e06 | ||
|
|
576afde7b7 |
No files matched your search
@@ -30,3 +30,4 @@ src/main/resources/mixins.*.json
|
||||
*.bat
|
||||
*.DS_Store
|
||||
!gradlew.bat
|
||||
layout.json
|
||||
@@ -3,17 +3,9 @@ Forestry
|
||||
|
||||
### What is it?
|
||||
|
||||
This is the GTNH fork of Forestry for 1.7.10. Do not report any issues to the original Forestry team. This fork is maintained by the GTNH team and is not supported by the original Forestry team.
|
||||
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
|
||||
|
||||
### Homepage
|
||||
|
||||
[Wiki](http://forestry.sengir.net/)
|
||||
|
||||
[Latest Builds for 1.7.10](http://jenkins.ic2.player.to/job/Forestry_Dev/)
|
||||
|
||||
[IRC #forestry on esper.net](http://webchat.esper.net/?nick=ForestryGithub...&channels=forestry&prompt=1)
|
||||
|
||||
For those interested in developement, you can also visit #forestry-dev.
|
||||
|
||||
### Building
|
||||
|
||||
@@ -31,8 +23,6 @@ Beware of ugly code.
|
||||
|
||||
Bugfixes are generally welcome. If you want to contribute something which changes game mechanics, please talk to someone with commit privileges first. Nothing is more frustrating than putting a lot of work and effort into a new game mechanic and then having the PR rejected because it doesn’t fit gameplay-wise.
|
||||
|
||||
**If you submit a PR you must accept the [Contributor License Agreement](https://cla-assistant.io/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
|
||||
|
||||
### License & Copyright
|
||||
|
||||
Forestry is (c) 2011 - 2014 SirSengir and licensed under LGPL v3. See the LICENSE.txt for all the gory details or go to http://www.gnu.org/licenses/lgpl-3.0.txt for more information. Forestry also contains code contributed by CovertJaguar, Player, MysteriousAges, Binnie, RichardG, cpw and others.
|
||||
Forestry is (c) 2011 - 2014 SirSengir and licensed under LGPL v3. See the LICENSE.txt for all the gory details or go to http://www.gnu.org/licenses/lgpl-3.0.txt for more information. Forestry also contains code contributed by CovertJaguar, Player, MysteriousAges, Binnie, RichardG, cpw, the GTNH Team, and others.
|
||||
+2
-1602
File diff suppressed because it is too large.
Load diff
+4
-3
@@ -2,9 +2,10 @@
|
||||
|
||||
dependencies {
|
||||
api('curse.maven:cofh-lib-220333:2388748')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.5.3-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.6.1:api')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.38:api')
|
||||
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta49:api')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.62-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
||||
}
|
||||
+95
-44
@@ -1,77 +1,109 @@
|
||||
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
|
||||
# LOCAL to test local config updates.
|
||||
gtnh.settings.blowdryerTag = 0.2.0
|
||||
|
||||
# Human-readable mod name, available for mcmod.info population.
|
||||
modName = Forestry
|
||||
|
||||
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
||||
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
|
||||
# Conventionally lowercase.
|
||||
modId = Forestry
|
||||
|
||||
# Root package of the mod, used to find various classes in other properties,
|
||||
# mcmod.info substitution, enabling assertions in run tasks, etc.
|
||||
modGroup = forestry
|
||||
|
||||
# WHY is there no version field?
|
||||
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
||||
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# When false, com.github.GTNewHorizons is used.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Will update your build.gradle automatically whenever an update is available
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
autoUpdateBuildScript = false
|
||||
|
||||
# Version of Minecraft to target
|
||||
minecraftVersion = 1.7.10
|
||||
|
||||
# Version of Minecraft Forge to target
|
||||
forgeVersion = 10.13.4.1614
|
||||
|
||||
# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task.
|
||||
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
|
||||
channel = stable
|
||||
|
||||
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
|
||||
mappingsVersion = 12
|
||||
|
||||
# Define other MCP mappings for dependency deobfuscation
|
||||
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
# Defines other MCP mappings for dependency deobfuscation.
|
||||
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
|
||||
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
|
||||
# restart Minecraft in development. Choose this dependent on your mod:
|
||||
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
||||
# Select a default username for testing your mod. You can always override this per-run by running
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience
|
||||
# Turns most publicly visible List, Map, etc. into proper List<Type>, Map<K, V> types
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
enableGenericInjection = true
|
||||
|
||||
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
|
||||
# Generate a class with a String field for the mod version named as defined below.
|
||||
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
|
||||
generateGradleTokenClass = forestry.Tags
|
||||
gradleTokenModId =
|
||||
gradleTokenModName =
|
||||
|
||||
# Name of the token containing the project's current version to generate/replace.
|
||||
gradleTokenVersion = VERSION
|
||||
|
||||
# [DEPRECATED] Mod ID replacement token.
|
||||
gradleTokenModId =
|
||||
|
||||
# [DEPRECATED] Mod name replacement token.
|
||||
gradleTokenModName =
|
||||
|
||||
# [DEPRECATED] Mod Group replacement token.
|
||||
gradleTokenGroupName =
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...])
|
||||
# Leave these properties empty to skip individual token replacements
|
||||
# version in @Mod([...], version = VERSION, [...]).
|
||||
# Leave these properties empty to skip individual token replacements.
|
||||
replaceGradleTokenInFile =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
||||
apiPackage = api
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a space-separated list.
|
||||
# Example value: mymodid_at.cfg nei_at.cfg
|
||||
accessTransformersFile =
|
||||
accessTransformersFile = forestry_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
# Adds some debug arguments like verbose output and export
|
||||
|
||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||
# Mixin classes will have access to "main" classes, but not the other way around.
|
||||
separateMixinSourceSet =
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = false
|
||||
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass =
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
containsMixinsAndOrCoreModOnly = false
|
||||
@@ -79,28 +111,38 @@ containsMixinsAndOrCoreModOnly = false
|
||||
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
||||
forceEnableMixins = false
|
||||
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
||||
# responsibility check the licence and request permission for distribution, if required.
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
|
||||
# responsibility to check the license and request permission for distribution if required.
|
||||
usesShadowedDependencies = false
|
||||
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
|
||||
|
||||
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
|
||||
# their own classes, making the minimization unreliable.
|
||||
minimizeShadowedDependencies = true
|
||||
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories
|
||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
|
||||
# list of strings, with the acceptable keys being(case does not matter):
|
||||
# cursemaven
|
||||
# modrinth
|
||||
excludeWellKnownRepositories =
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
# Authenticate with the MAVEN_USERNAME and MAVEN_PASSWORD environment variables.
|
||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||
usesMavenPublishing = true
|
||||
# mavenPublishUrl = http://jenkins.usrv.eu:8081/nexus/content/repositories/releases
|
||||
|
||||
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
|
||||
# Maven repository to publish the mod to.
|
||||
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
|
||||
|
||||
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
||||
#
|
||||
# The project's ID on Modrinth. Can be either the slug or the ID.
|
||||
# Leave this empty if you don't want to publish on Modrinth.
|
||||
# Leave this empty if you don't want to publish to Modrinth.
|
||||
modrinthProjectId =
|
||||
|
||||
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
||||
@@ -112,9 +154,8 @@ modrinthProjectId =
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
modrinthRelations =
|
||||
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
|
||||
#
|
||||
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
||||
# Leave this empty if you don't want to publish on CurseForge.
|
||||
curseForgeProjectId =
|
||||
@@ -124,29 +165,39 @@ curseForgeProjectId =
|
||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||
# and the name is the CurseForge project slug of the other mod.
|
||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
curseForgeRelations =
|
||||
|
||||
|
||||
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
||||
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to prevent the source code from being published
|
||||
# noPublishedSources =
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
|
||||
# versionPattern =
|
||||
|
||||
# Uncomment this to disable spotless checks
|
||||
# Uncomment to prevent the source code from being published.
|
||||
# noPublishedSources = true
|
||||
|
||||
# Uncomment this to disable Spotless checks.
|
||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
||||
# disableSpotless = true
|
||||
|
||||
# Uncomment this to disable checkstyle checks (currently wildcard import check).
|
||||
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
|
||||
# disableCheckstyle = true
|
||||
|
||||
# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# (force use delegated build).
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build.
|
||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
|
||||
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
||||
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
||||
# ideaOverrideBuildType = idea
|
||||
|
||||
# Whether IDEA should run spotless checks when pressing the Build button.
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
Vendored
+12
-10
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
+3
-7
@@ -6,6 +6,7 @@ pluginManagement {
|
||||
name "GTNH Maven"
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons")
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
}
|
||||
}
|
||||
@@ -16,12 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.diffplug.blowdryerSetup' version '1.7.1'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
|
||||
}
|
||||
|
||||
blowdryerSetup {
|
||||
repoSubfolder 'gtnhShared'
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
|
||||
//devLocal '.' // Use this when testing config updates locally
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
@@ -79,11 +80,15 @@ public class Forestry {
|
||||
|
||||
public static PacketHandler packetHandler;
|
||||
|
||||
public static boolean isDreamcraftLoaded;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
checkForCoFHLib();
|
||||
packetHandler = new PacketHandler();
|
||||
|
||||
isDreamcraftLoaded = Loader.isModLoaded("dreamcraft");
|
||||
|
||||
// Register event handler
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
|
||||
@@ -12,11 +12,15 @@ public interface IClimateControlled {
|
||||
|
||||
/**
|
||||
* Change the temperature, but not lower than boundaryDown or higher than boundaryUp.
|
||||
*
|
||||
* When used in an alveary the change applies a 20x stronger effect
|
||||
*/
|
||||
void addTemperatureChange(float change, float boundaryDown, float boundaryUp);
|
||||
|
||||
/**
|
||||
* Change the humidity, but not lower than boundaryDown or higher than boundaryUp.
|
||||
*
|
||||
* When used in an alveary the change applies a 20x stronger effect
|
||||
*/
|
||||
void addHumidityChange(float change, float boundaryDown, float boundaryUp);
|
||||
}
|
||||
@@ -9,33 +9,37 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RainSubstrate {
|
||||
|
||||
public enum WeatherState {
|
||||
CLEAR,
|
||||
RAIN,
|
||||
STORM
|
||||
}
|
||||
|
||||
/**
|
||||
* Rain substrate capable of activating the rainmaker.
|
||||
*/
|
||||
public ItemStack item;
|
||||
/**
|
||||
* Duration of the rain shower triggered by this substrate in Minecraft ticks.
|
||||
* Duration of the weather event triggered by this substrate in Minecraft ticks.
|
||||
*/
|
||||
public int duration;
|
||||
/**
|
||||
* Speed of activation sequence triggered.
|
||||
*/
|
||||
public float speed;
|
||||
/**
|
||||
* The type of weather triggered.
|
||||
*/
|
||||
public WeatherState weather;
|
||||
|
||||
public boolean reverse;
|
||||
|
||||
public RainSubstrate(ItemStack item, int duration, float speed) {
|
||||
this(item, duration, speed, false);
|
||||
public RainSubstrate(ItemStack item, float speed, WeatherState weather) {
|
||||
this(item, 0, speed, weather);
|
||||
}
|
||||
|
||||
public RainSubstrate(ItemStack item, float speed) {
|
||||
this(item, 0, speed, true);
|
||||
}
|
||||
|
||||
public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) {
|
||||
public RainSubstrate(ItemStack item, int duration, float speed, WeatherState weather) {
|
||||
this.item = item;
|
||||
this.duration = duration;
|
||||
this.speed = speed;
|
||||
this.reverse = reverse;
|
||||
this.weather = weather;
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,8 @@ public interface IIndividual extends INBTTagable {
|
||||
IIndividual copy();
|
||||
|
||||
boolean isPureBred(IChromosomeType chromosomeType);
|
||||
|
||||
default void addLore(List<String> text) {}
|
||||
|
||||
default void addDiscoveredBy(List<String> text) {}
|
||||
}
|
||||
@@ -49,6 +49,14 @@ public interface IAlvearyComponent<T extends IMultiblockLogicAlveary> extends IM
|
||||
* @param alveary the climate controlled alveary
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateControlled alveary);
|
||||
|
||||
/**
|
||||
* Get the priority of this climatiser. Called when alveary is constructed.
|
||||
* {@link #changeClimate(int, IClimateControlled)} are run in descending priority.
|
||||
*/
|
||||
default int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,8 @@ import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
|
||||
/**
|
||||
* Basic interface for a multiblock machine component. Implemented by TileEntities.
|
||||
*/
|
||||
@@ -45,4 +47,15 @@ public interface IMultiblockComponent {
|
||||
* Called when the machine is broken for game reasons, e.g. a player removed a block or an explosion occurred.
|
||||
*/
|
||||
void onMachineBroken();
|
||||
|
||||
/**
|
||||
* A component with a separate inventory, like the Alveary Swarmer or Alveary Sieve.
|
||||
*/
|
||||
interface HasInventory {
|
||||
|
||||
/**
|
||||
* Called when this part is destroyed to drop its contents.
|
||||
*/
|
||||
IInventoryAdapter getInternalInventory();
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
Stack<ItemStack> spawnCopy = new Stack<>();
|
||||
if (spawn.size() < 128) spawnCopy.addAll(spawn);
|
||||
else for (byte b = 0; b < 128; ++b) spawnCopy.add(spawn.get(b));
|
||||
else for (int b = 0; b < 128; ++b) spawnCopy.add(spawn.get(b));
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
while (!spawnCopy.isEmpty() && spawnCopy.size() <= 128) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class BlockAlveary extends BlockStructure {
|
||||
/* TILE ENTITY CREATION */
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
if (metadata < 0 || metadata > Type.VALUES.length) {
|
||||
if (metadata < 0 || metadata >= Type.VALUES.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
|
||||
|
||||
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers,
|
||||
World world, int x, int y, int z) {
|
||||
if (!world.blockExists(x, y, z)) return false;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
final int meta;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual,
|
||||
int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
|
||||
}
|
||||
|
||||
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.blockExists(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityFlowerPot)) {
|
||||
return false;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import static forestry.core.utils.MathUtil.safeAdd;
|
||||
import static forestry.core.utils.MathUtil.safeMultiply;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -15,6 +18,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -373,6 +378,36 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return suitableBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLore(List<String> text) {
|
||||
IAlleleBeeSpecies primary = genome.getPrimary();
|
||||
String descTokens[] = primary.getDescription().split("\\|");
|
||||
|
||||
if (descTokens.length > 0) {
|
||||
String speciesLore = descTokens[0];
|
||||
if (!speciesLore.isEmpty() && !speciesLore.contains("for.description")) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
String formattedLore = EnumChatFormatting.GOLD + speciesLore;
|
||||
List<String> formattedLoreList = fontRenderer.listFormattedStringToWidth(formattedLore, 200);
|
||||
text.addAll(formattedLoreList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDiscoveredBy(List<String> text) {
|
||||
IAlleleBeeSpecies primary = genome.getPrimary();
|
||||
String descTokens[] = primary.getDescription().split("\\|");
|
||||
|
||||
if (descTokens.length > 2) {
|
||||
String discoveredBy = descTokens[2];
|
||||
if (!discoveredBy.isEmpty()) {
|
||||
text.add("");
|
||||
text.add("Discovered by " + EnumChatFormatting.ITALIC + discoveredBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(List<String> list) {
|
||||
|
||||
@@ -699,9 +734,9 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
// boost chance for researched mutations
|
||||
if (breedingTracker.isResearched(beeMutation)) {
|
||||
float mutationBoost = chance * (Config.researchMutationBoostMultiplier - 1.0f);
|
||||
float mutationBoost = safeMultiply(chance, Config.researchMutationBoostMultiplier - 1.0f);
|
||||
mutationBoost = Math.min(Config.maxResearchMutationBoostPercent, mutationBoost);
|
||||
chance += mutationBoost;
|
||||
chance = safeAdd(chance, mutationBoost);
|
||||
}
|
||||
|
||||
if (chance > world.rand.nextFloat() * 100) {
|
||||
@@ -738,6 +773,9 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect blockPos = Vect.add(housingPos, randomPos, offset);
|
||||
if (!world.blockExists(blockPos.x, blockPos.y, blockPos.z)) {
|
||||
continue;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
|
||||
|
||||
if (tile instanceof IPollinatable) {
|
||||
|
||||
@@ -331,7 +331,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SIMMERING, 1), 0.55f)
|
||||
.addProduct(PluginCore.items.ash.getItemStack(), 0.15f).setTemperature(EnumTemperature.HELLISH)
|
||||
.addProduct(PluginCore.items.getAsh(), 0.15f).setTemperature(EnumTemperature.HELLISH)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import static forestry.core.utils.MathUtil.safeMultiply;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -49,8 +51,8 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
|
||||
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
|
||||
|
||||
processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
|
||||
processedChance *= beeModeModifier.getMutationModifier(genome0, genome1, processedChance);
|
||||
processedChance = safeMultiply(processedChance, beeHousingModifier.getMutationModifier(genome0, genome1, 1.0F));
|
||||
processedChance = safeMultiply(processedChance, beeModeModifier.getMutationModifier(genome0, genome1, 1.0F));
|
||||
|
||||
return processedChance;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
@@ -21,7 +22,7 @@ import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
import forestry.apiculture.multiblock.AlvearyController;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
@@ -36,8 +37,13 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
harmEntities(genome, housing);
|
||||
if (isMobGriefingEnabled(housing)) destroyEnvironment(genome, housing);
|
||||
|
||||
return destroyEnvironment(genome, storedData, housing);
|
||||
return storedData;
|
||||
}
|
||||
|
||||
private boolean isMobGriefingEnabled(IBeeHousing housing) {
|
||||
return housing.getWorld().getGameRules().getGameRuleBooleanValue("mobGriefing");
|
||||
}
|
||||
|
||||
private void harmEntities(IBeeGenome genome, IBeeHousing housing) {
|
||||
@@ -56,7 +62,7 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
}
|
||||
}
|
||||
|
||||
private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
private static void destroyEnvironment(IBeeGenome genome, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
Random rand = world.rand;
|
||||
|
||||
@@ -65,43 +71,66 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
Vect offset = area.multiply(-1 / 2.0f);
|
||||
Vect posHousing = new Vect(housing.getCoordinates());
|
||||
|
||||
boolean isAlveary = housing instanceof AlvearyController;
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(rand, area);
|
||||
Vect posBlock = randomPos.add(posHousing);
|
||||
posBlock = posBlock.add(offset);
|
||||
Vect posBlock = randomPos.add(posHousing).add(offset);
|
||||
|
||||
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
|
||||
// Don't destroy blocks in the protected 3x3x4 area if housing is an Alveary.
|
||||
// Stops the bee destroying itself. Silly behaviour.
|
||||
if (isInAlvearyProtectedArea(posHousing, posBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't destroy ourselves or blocks below us.
|
||||
if (posBlock.x == posHousing.x && posBlock.z == posHousing.z && posBlock.y <= posHousing.y) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
|
||||
continue;
|
||||
// Don't destroy the block directly below the bee.
|
||||
if (isAlveary) {
|
||||
if (posBlock.y == posHousing.y - 3) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (posBlock.y == posHousing.y - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
|
||||
|
||||
if (block instanceof BlockAlveary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Never delete a tile entity. Allows far too much griefing and abuse otherwise.
|
||||
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
|
||||
if (tile instanceof IBeeHousing) {
|
||||
if (tile != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't let us delete blocks that are not supposed to be breakable by players.
|
||||
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some mods might use this logic? Idk, just a safety check. Might stop griefing.
|
||||
EntityPlayer player = world.func_152378_a(housing.getOwner().getId());
|
||||
if (player == null || !world.canMineBlock(player, posHousing.x, posHousing.y, posHousing.z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return storedData;
|
||||
private static boolean isInAlvearyProtectedArea(Vect posHousing, Vect posBlock) {
|
||||
// Alveary protection area is a 3x3x4 area centered on the top middle, down one block.
|
||||
int startX = posHousing.x - 1;
|
||||
int endX = posHousing.x + 1;
|
||||
int startZ = posHousing.z - 1;
|
||||
int endZ = posHousing.z + 1;
|
||||
int startY = posHousing.y - 2;
|
||||
int endY = posHousing.y + 1;
|
||||
|
||||
return posBlock.x >= startX && posBlock.x <= endX
|
||||
&& posBlock.z >= startZ
|
||||
&& posBlock.z <= endZ
|
||||
&& posBlock.y >= startY
|
||||
&& posBlock.y <= endY;
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,8 @@ public class ItemHabitatLocator extends ItemWithGui {
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
|
||||
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ);
|
||||
|
||||
float temperatureValue = currentBiome
|
||||
.getFloatTemperature((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
|
||||
EnumTemperature temperature = EnumTemperature
|
||||
.getFromBiome(currentBiome, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall);
|
||||
|
||||
list.add(StringUtil.localize("gui.currentBiome") + ": " + currentBiome.biomeName);
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -59,7 +61,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
// PARTS
|
||||
private final Set<IBeeModifier> beeModifiers = new HashSet<>();
|
||||
private final Set<IBeeListener> beeListeners = new HashSet<>();
|
||||
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<>();
|
||||
private final Set<IAlvearyComponent.Climatiser> climatisers = new TreeSet<>(
|
||||
Comparator.comparingInt(IAlvearyComponent.Climatiser::getPriority).thenComparingInt(Object::hashCode)
|
||||
.reversed());
|
||||
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<>();
|
||||
|
||||
// CLIENT
|
||||
@@ -233,26 +237,24 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
beekeepingLogic.doWork();
|
||||
}
|
||||
|
||||
tempChange = 0;
|
||||
humidChange = 0;
|
||||
for (IAlvearyComponent.Climatiser climatiser : climatisers) {
|
||||
climatiser.changeClimate(tickCount, this);
|
||||
}
|
||||
|
||||
tempChange = equalizeChange(tempChange);
|
||||
humidChange = equalizeChange(humidChange);
|
||||
|
||||
return canWork;
|
||||
}
|
||||
|
||||
private static float equalizeChange(float change) {
|
||||
if (change == 0) {
|
||||
return 0;
|
||||
private float applyChange(float base, float currentChange, float extraChange, float boundaryDown,
|
||||
float boundaryUp) {
|
||||
float boundedNewChange = Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp))
|
||||
- base;
|
||||
if (extraChange > 0) {
|
||||
return Math.max(currentChange, boundedNewChange);
|
||||
} else {
|
||||
return Math.min(currentChange, boundedNewChange);
|
||||
}
|
||||
|
||||
change *= 0.95f;
|
||||
if (change <= 0.001f && change >= -0.001f) {
|
||||
change = 0;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,19 +412,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
ChunkCoordinates coordinates = getCoordinates();
|
||||
|
||||
float temperature = getBiome().getFloatTemperature(coordinates.posX, coordinates.posY, coordinates.posZ);
|
||||
|
||||
tempChange += change;
|
||||
tempChange = Math.max(boundaryDown - temperature, tempChange);
|
||||
tempChange = Math.min(boundaryUp - temperature, tempChange);
|
||||
tempChange = applyChange(temperature, tempChange, change, boundaryDown, boundaryUp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float humidity = getBiome().rainfall;
|
||||
|
||||
humidChange += change;
|
||||
humidChange = Math.max(boundaryDown - humidity, humidChange);
|
||||
humidChange = Math.min(boundaryUp - humidity, humidChange);
|
||||
humidChange = applyChange(humidity, humidChange, change, boundaryDown, boundaryUp);
|
||||
}
|
||||
|
||||
/* GUI */
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
import forestry.apiculture.gui.GuiAlvearyHygroregulator;
|
||||
@@ -31,8 +32,8 @@ import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
public class TileAlvearyHygroregulator extends TileAlveary
|
||||
implements IInventory, ILiquidTankTile, IFluidHandler, IAlvearyComponent.Climatiser {
|
||||
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IFluidHandler,
|
||||
IAlvearyComponent.Climatiser, IMultiblockComponent.HasInventory {
|
||||
|
||||
private final HygroregulatorRecipe[] recipes;
|
||||
|
||||
@@ -56,9 +57,9 @@ public class TileAlvearyHygroregulator extends TileAlveary
|
||||
this.tankManager = new TankManager(this, liquidTank);
|
||||
|
||||
this.recipes = new HygroregulatorRecipe[] {
|
||||
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.0005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.0005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.001f) };
|
||||
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.01f) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +112,11 @@ public class TileAlvearyHygroregulator extends TileAlveary
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
import forestry.apiculture.gui.ContainerAlvearySieve;
|
||||
import forestry.apiculture.gui.GuiAlvearySieve;
|
||||
@@ -25,7 +26,8 @@ import forestry.apiculture.inventory.InventoryAlvearySieve;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.watchers.ISlotPickupWatcher;
|
||||
|
||||
public class TileAlvearySieve extends TileAlveary implements IAlvearyComponent.BeeListener {
|
||||
public class TileAlvearySieve extends TileAlveary
|
||||
implements IAlvearyComponent.BeeListener, IMultiblockComponent.HasInventory {
|
||||
|
||||
private final IBeeListener beeListener;
|
||||
private final InventoryAlvearySieve inventory;
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -21,6 +22,7 @@ import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
import forestry.apiculture.gui.ContainerAlvearySwarmer;
|
||||
import forestry.apiculture.gui.GuiAlvearySwarmer;
|
||||
@@ -36,10 +38,11 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
|
||||
public class TileAlvearySwarmer extends TileAlveary
|
||||
implements ISidedInventory, IActivatable, IAlvearyComponent.Active, IMultiblockComponent.HasInventory {
|
||||
|
||||
private final InventorySwarmer inventory;
|
||||
private final Stack<ItemStack> pendingSpawns = new Stack<>();
|
||||
private final Deque<ItemStack> pendingSpawns = new ArrayDeque<>();
|
||||
private boolean active;
|
||||
|
||||
public TileAlvearySwarmer() {
|
||||
|
||||
@@ -15,11 +15,14 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import forestry.apiculture.blocks.BlockCandle;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
@@ -58,7 +61,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
|
||||
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
|
||||
|
||||
int colour = tileCandle.getColour();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
double d0 = 0.4000000059604645D;
|
||||
@@ -87,7 +90,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10,
|
||||
int colour) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
double minU = icon.getMinU();
|
||||
double minV = icon.getMinV();
|
||||
double maxU = icon.getMaxU();
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -298,6 +300,36 @@ public class Tree extends Individual implements ITree, IPlantable {
|
||||
return plantTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLore(List<String> text) {
|
||||
IAlleleTreeSpecies primary = genome.getPrimary();
|
||||
String descTokens[] = primary.getDescription().split("\\|");
|
||||
|
||||
if (descTokens.length > 0) {
|
||||
String speciesLore = descTokens[0];
|
||||
if (!speciesLore.isEmpty() && !speciesLore.contains("for.description")) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
String formattedLore = EnumChatFormatting.GOLD + speciesLore;
|
||||
List<String> formattedLoreList = fontRenderer.listFormattedStringToWidth(formattedLore, 200);
|
||||
text.addAll(formattedLoreList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDiscoveredBy(List<String> text) {
|
||||
IAlleleTreeSpecies primary = genome.getPrimary();
|
||||
String descTokens[] = primary.getDescription().split("\\|");
|
||||
|
||||
if (descTokens.length > 2) {
|
||||
String discoveredBy = descTokens[2];
|
||||
if (!discoveredBy.isEmpty()) {
|
||||
text.add("");
|
||||
text.add("Discovered by " + EnumChatFormatting.ITALIC + discoveredBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(List<String> list) {
|
||||
|
||||
|
||||
@@ -15,11 +15,14 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import forestry.arboriculture.blocks.BlockFruitPod;
|
||||
import forestry.arboriculture.tiles.TileFruitPod;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderFruitPodBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
@@ -37,7 +40,7 @@ public class RenderFruitPodBlock implements ISimpleBlockRenderingHandler {
|
||||
maturity = pod.getMaturity();
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(blockPod.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1.0f, 1.0f, 1.0f);
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.render.RenderOverlayBlock;
|
||||
@@ -22,6 +24,7 @@ import forestry.plugins.PluginArboriculture;
|
||||
/**
|
||||
* Ugly but serviceable renderer for leaves, taking fruits into account.
|
||||
*/
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderLeavesBlock extends RenderOverlayBlock {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
@@ -22,10 +24,9 @@ import forestry.arboriculture.blocks.BlockSapling;
|
||||
import forestry.arboriculture.tiles.TileSapling;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private static int renderLayer = 0;
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {}
|
||||
|
||||
@@ -45,10 +46,8 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
IAlleleTreeSpecies species = tile.getTree().getGenome().getPrimary();
|
||||
|
||||
renderCrossedSquares(species, world, block, x, y, z);
|
||||
renderLayer = 1;
|
||||
renderCrossedSquares(species, world, block, x, y, z);
|
||||
renderLayer = 0;
|
||||
renderCrossedSquares(species, world, block, x, y, z, 0);
|
||||
renderCrossedSquares(species, world, block, x, y, z, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,9 +62,9 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
private static boolean renderCrossedSquares(IAlleleTreeSpecies species, IBlockAccess world, Block block, int x,
|
||||
int y, int z) {
|
||||
int y, int z, int renderLayer) {
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
|
||||
tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
int colourMultiplier = species.getGermlingColour(EnumGermlingType.SAPLING, renderLayer);
|
||||
@@ -81,14 +80,14 @@ public class RenderSaplingBlock implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
tess.setColorOpaque_F(r, g, b);
|
||||
drawCrossedSquares(species, x, y, z, 1.0f);
|
||||
drawCrossedSquares(species, x, y, z, 1.0f, renderLayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void drawCrossedSquares(IAlleleTreeSpecies species, double par3, double par5, double par7,
|
||||
float mod) {
|
||||
private static void drawCrossedSquares(IAlleleTreeSpecies species, double par3, double par5, double par7, float mod,
|
||||
int renderLayer) {
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
IIcon icon = species.getGermlingIcon(EnumGermlingType.SAPLING, renderLayer);
|
||||
|
||||
double d3 = (double) icon.getMinU();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.blocks;
|
||||
|
||||
import static forestry.Forestry.isDreamcraftLoaded;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,7 +54,7 @@ public class BlockResourceOre extends Block {
|
||||
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int metadata, float par6, int par7) {
|
||||
super.dropBlockAsItemWithChance(world, x, y, z, metadata, par6, par7);
|
||||
|
||||
if (metadata == 0) {
|
||||
if (metadata == 0 && !isDreamcraftLoaded) {
|
||||
this.dropXpOnBlockBreak(world, x, y, z, MathHelper.getRandomIntegerInRange(world.rand, 1, 4));
|
||||
}
|
||||
}
|
||||
@@ -61,7 +63,7 @@ public class BlockResourceOre extends Block {
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> drops = new ArrayList<>();
|
||||
|
||||
if (metadata == ResourceType.APATITE.ordinal()) {
|
||||
if (metadata == ResourceType.APATITE.ordinal() && !isDreamcraftLoaded) {
|
||||
int fortuneModifier = world.rand.nextInt(fortune + 2) - 1;
|
||||
if (fortuneModifier < 0) {
|
||||
fortuneModifier = 0;
|
||||
|
||||
@@ -116,6 +116,12 @@ public abstract class BlockStructure extends BlockForestry {
|
||||
InventoryUtil.dropSockets((ISocketable) tile, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (tile instanceof IMultiblockComponent.HasInventory) {
|
||||
IMultiblockComponent.HasInventory hasInventory = (IMultiblockComponent.HasInventory) tile;
|
||||
|
||||
InventoryUtil.dropInventory(hasInventory.getInternalInventory(), world, x, y, z);
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ public class Constants implements IForestryConstants {
|
||||
public static final int MACHINE_MAX_ENERGY = 5000;
|
||||
|
||||
public static final int RAINMAKER_RAIN_DURATION_IODINE = 10000;
|
||||
public static final int RAINMAKER_RAIN_DURATION_PHOSPHORICIODINE = 10000;
|
||||
|
||||
public static final int STILL_DESTILLATION_DURATION = 100;
|
||||
public static final int STILL_DESTILLATION_INPUT = 10;
|
||||
|
||||
@@ -72,6 +72,12 @@ public abstract class ItemGE extends ItemForestry {
|
||||
if (individual.isAnalyzed()) {
|
||||
if (Proxies.common.isShiftDown()) {
|
||||
individual.addTooltip(list);
|
||||
individual.addDiscoveredBy(list);
|
||||
if (Proxies.common.isCtrlDown()) {
|
||||
individual.addLore(list);
|
||||
} else {
|
||||
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tml") + ">");
|
||||
}
|
||||
} else {
|
||||
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics.mutations;
|
||||
|
||||
import static forestry.core.utils.MathUtil.safeMultiply;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -126,7 +128,9 @@ public abstract class Mutation implements IMutationCustom {
|
||||
IGenome genome1, IClimateProvider climate) {
|
||||
float mutationChance = chance;
|
||||
for (IMutationCondition mutationCondition : mutationConditions) {
|
||||
mutationChance *= mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate);
|
||||
mutationChance = safeMultiply(
|
||||
mutationChance,
|
||||
mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate));
|
||||
if (mutationChance == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,4 +53,13 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
|
||||
inventory.onSlotClick(player);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (!inventory.isParentItemEquipped()) {
|
||||
inventory.getPlayer().closeScreen();
|
||||
return;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import forestry.core.network.packets.PacketAccessUpdate;
|
||||
import forestry.core.network.packets.PacketErrorUpdate;
|
||||
import forestry.core.network.packets.PacketGuiEnergy;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
import forestry.core.network.packets.PacketTileConfiguration;
|
||||
import forestry.core.tiles.IConfigurable;
|
||||
import forestry.core.tiles.IPowerHandler;
|
||||
import forestry.core.tiles.TilePowered;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
@@ -34,6 +36,7 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
||||
|
||||
protected final T tile;
|
||||
private final IAccessHandler accessHandler;
|
||||
private boolean configurationChanged;
|
||||
|
||||
protected ContainerTile(T tile) {
|
||||
this.tile = tile;
|
||||
@@ -43,6 +46,10 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
||||
} else {
|
||||
accessHandler = FakeAccessHandler.getInstance();
|
||||
}
|
||||
|
||||
if (tile instanceof IConfigurable) {
|
||||
configurationChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected ContainerTile(T tileForestry, InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||
@@ -128,6 +135,15 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
||||
sendPacketToCrafters(packet);
|
||||
}
|
||||
}
|
||||
|
||||
if (tile instanceof IConfigurable && configurationChanged) {
|
||||
configurationChanged = false;
|
||||
sendPacketToCrafters(new PacketTileConfiguration(tile));
|
||||
}
|
||||
}
|
||||
|
||||
protected void markConfigurationDirty() {
|
||||
configurationChanged = true;
|
||||
}
|
||||
|
||||
public void onGuiEnergy(int energyStored) {
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -208,7 +209,7 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
textLayout.drawLine(StringUtil.localize("gui.alyzer.classification") + ":", 12);
|
||||
textLayout.newLine();
|
||||
|
||||
Stack<IClassification> hierarchy = new Stack<>();
|
||||
Deque<IClassification> hierarchy = new ArrayDeque<>();
|
||||
IClassification classification = individual.getGenome().getPrimary().getBranch();
|
||||
while (classification != null) {
|
||||
|
||||
|
||||
@@ -138,6 +138,10 @@ public abstract class Ledger {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean acceptMouseButton(int mouseButton) {
|
||||
return mouseButton == 0;
|
||||
}
|
||||
|
||||
public boolean intersectsWith(int mouseX, int mouseY) {
|
||||
return mouseX >= currentShiftX && mouseX <= currentShiftX + currentWidth
|
||||
&& mouseY >= currentShiftY
|
||||
|
||||
@@ -159,29 +159,28 @@ public class LedgerManager {
|
||||
}
|
||||
|
||||
public void handleMouseClicked(int x, int y, int mouseButton) {
|
||||
Ledger ledger = this.getAtPosition(x, y);
|
||||
if (ledger == null || !ledger.acceptMouseButton(mouseButton)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mouseButton == 0) {
|
||||
// Default action only if the mouse click was not handled by the
|
||||
// ledger itself.
|
||||
if (!ledger.handleMouseClicked(x, y, mouseButton)) {
|
||||
|
||||
Ledger ledger = this.getAtPosition(x, y);
|
||||
|
||||
// Default action only if the mouse click was not handled by the
|
||||
// ledger itself.
|
||||
if (ledger != null && !ledger.handleMouseClicked(x, y, mouseButton)) {
|
||||
|
||||
List<? extends Ledger> toggleLedgers;
|
||||
if (ledgers.contains(ledger)) {
|
||||
toggleLedgers = ledgers;
|
||||
} else {
|
||||
toggleLedgers = errorLedgers;
|
||||
}
|
||||
|
||||
for (Ledger other : toggleLedgers) {
|
||||
if (other != ledger && other.isOpen()) {
|
||||
other.toggleOpen();
|
||||
}
|
||||
}
|
||||
ledger.toggleOpen();
|
||||
List<? extends Ledger> toggleLedgers;
|
||||
if (ledgers.contains(ledger)) {
|
||||
toggleLedgers = ledgers;
|
||||
} else {
|
||||
toggleLedgers = errorLedgers;
|
||||
}
|
||||
|
||||
for (Ledger other : toggleLedgers) {
|
||||
if (other != ledger && other.isOpen()) {
|
||||
other.toggleOpen();
|
||||
}
|
||||
}
|
||||
ledger.toggleOpen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.tiles.IIngredientsSearchController;
|
||||
import forestry.core.tiles.IngredientsStorage;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class SearchIngregientsLedger extends Ledger {
|
||||
|
||||
private final IIngredientsSearchController ingredientsSearch;
|
||||
|
||||
public SearchIngregientsLedger(LedgerManager manager, IIngredientsSearchController ingredientsSearch) {
|
||||
super(manager, "search_ingredients");
|
||||
this.ingredientsSearch = ingredientsSearch;
|
||||
this.maxHeight = 36;
|
||||
}
|
||||
|
||||
private boolean isSwitchButton(int mouseX, int mouseY) {
|
||||
int shiftX = currentShiftX + 20;
|
||||
int shiftY = currentShiftY + 8;
|
||||
return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 24;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
// Draw icon
|
||||
IIcon icon = TextureManager.getInstance().getDefault(
|
||||
"misc/search_ingredients."
|
||||
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
|
||||
drawIcon(icon, x + 3, y + 4);
|
||||
|
||||
// Draw description
|
||||
if (!isFullyOpened()) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawHeader(StringUtil.localize("gui.search_ingredients"), x + 22, y + 8);
|
||||
drawText(
|
||||
StringUtil.localize(
|
||||
"gui.search_ingredients."
|
||||
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH)),
|
||||
x + 22,
|
||||
y + 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return StringUtil.localize("gui.search_ingredients") + ": "
|
||||
+ StringUtil.localize(
|
||||
"gui.search_ingredients."
|
||||
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMouseClicked(int x, int y, int mouseButton) {
|
||||
if (isSwitchButton(x, y)) {
|
||||
IngredientsStorage ingredientsStorage = ingredientsSearch.getIngredientsStorage();
|
||||
IngredientsStorage newIngredientsStorage = mouseButton == 0 ? ingredientsStorage.next()
|
||||
: ingredientsStorage.previous();
|
||||
ingredientsSearch.setIngredientsStorage(newIngredientsStorage);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptMouseButton(int mouseButton) {
|
||||
return mouseButton == 0 || mouseButton == 1;
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,14 @@ public class SlotCrafter extends SlotCrafting {
|
||||
|
||||
private final IInventory craftMatrix;
|
||||
private final ICrafterWorktable crafter;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafterWorktable crafter, int slot, int xPos,
|
||||
int yPos) {
|
||||
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
|
||||
this.craftMatrix = craftMatrix;
|
||||
this.crafter = crafter;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +41,7 @@ public class SlotCrafter extends SlotCrafting {
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return crafter.canTakeStack(getSlotIndex());
|
||||
return crafter.canTakeStack(player, getSlotIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +51,7 @@ public class SlotCrafter extends SlotCrafting {
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return getStack() != null && crafter.canTakeStack(getSlotIndex());
|
||||
return getStack() != null && crafter.canTakeStack(player, getSlotIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,6 +78,14 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isParentItemEquipped() {
|
||||
return isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public boolean isParentItemInventory(ItemStack itemStack) {
|
||||
ItemStack parent = getParent();
|
||||
return isSameItemInventory(parent, itemStack);
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package forestry.core.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MergedInventories implements IInventory {
|
||||
|
||||
private final IInventory first;
|
||||
private final IInventory second;
|
||||
|
||||
public MergedInventories(IInventory first, IInventory second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return first.getSizeInventory() + second.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIn) {
|
||||
if (slotIn < first.getSizeInventory()) {
|
||||
return first.getStackInSlot(slotIn);
|
||||
}
|
||||
return second.getStackInSlot(slotIn - first.getSizeInventory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (index < first.getSizeInventory()) {
|
||||
return first.decrStackSize(index, count);
|
||||
}
|
||||
return second.decrStackSize(index - first.getSizeInventory(), count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int index) {
|
||||
if (index < first.getSizeInventory()) {
|
||||
return first.getStackInSlotOnClosing(index);
|
||||
}
|
||||
return second.getStackInSlotOnClosing(index - first.getSizeInventory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack) {
|
||||
if (index < first.getSizeInventory()) {
|
||||
first.setInventorySlotContents(index, stack);
|
||||
} else {
|
||||
second.setInventorySlotContents(index - first.getSizeInventory(), stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return first.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return first.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return Math.min(first.getInventoryStackLimit(), second.getInventoryStackLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
first.markDirty();
|
||||
second.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return first.isUseableByPlayer(player) && second.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
first.openInventory();
|
||||
second.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
first.closeInventory();
|
||||
second.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
if (index < first.getSizeInventory()) {
|
||||
return first.isItemValidForSlot(index, stack);
|
||||
}
|
||||
return second.isItemValidForSlot(index - first.getSizeInventory(), stack);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import static forestry.Forestry.isDreamcraftLoaded;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -63,7 +67,7 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
|
||||
/* Peat */
|
||||
public final ItemForestry peat;
|
||||
public final ItemForestry ash;
|
||||
private final ItemForestry ash;
|
||||
public final ItemForestry bituminousPeat;
|
||||
|
||||
/* Moistener */
|
||||
@@ -74,6 +78,7 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
/* Rainmaker */
|
||||
public final ItemForestry iodineCharge;
|
||||
public final ItemForestry phosphor;
|
||||
public final ItemForestry phosphorCharge;
|
||||
|
||||
/* Misc */
|
||||
public final ItemCraftingMaterial craftingMaterial;
|
||||
@@ -87,19 +92,26 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
fertilizerBio = registerItem(new ItemForestry(), "fertilizerBio");
|
||||
fertilizerCompound = registerItem(new ItemForestryBonemeal(), "fertilizerCompound");
|
||||
|
||||
apatite = registerItem(new ItemForestry(), "apatite");
|
||||
OreDictionary.registerOre("gemApatite", apatite);
|
||||
|
||||
researchNote = registerItem(new ItemResearchNote(), "researchNote");
|
||||
|
||||
ingotCopper = registerItem(new ItemForestry(), "ingotCopper");
|
||||
OreDictionary.registerOre("ingotCopper", ingotCopper);
|
||||
if (!isDreamcraftLoaded) {
|
||||
apatite = registerItem(new ItemForestry(), "apatite");
|
||||
OreDictionary.registerOre("gemApatite", apatite);
|
||||
|
||||
ingotTin = registerItem(new ItemForestry(), "ingotTin");
|
||||
OreDictionary.registerOre("ingotTin", ingotTin);
|
||||
ingotCopper = registerItem(new ItemForestry(), "ingotCopper");
|
||||
OreDictionary.registerOre("ingotCopper", ingotCopper);
|
||||
|
||||
ingotBronze = registerItem(new ItemForestry(), "ingotBronze");
|
||||
OreDictionary.registerOre("ingotBronze", ingotBronze);
|
||||
ingotTin = registerItem(new ItemForestry(), "ingotTin");
|
||||
OreDictionary.registerOre("ingotTin", ingotTin);
|
||||
|
||||
ingotBronze = registerItem(new ItemForestry(), "ingotBronze");
|
||||
OreDictionary.registerOre("ingotBronze", ingotBronze);
|
||||
} else {
|
||||
apatite = null;
|
||||
ingotCopper = null;
|
||||
ingotTin = null;
|
||||
ingotBronze = null;
|
||||
}
|
||||
|
||||
wrench = registerItem(new ItemWrench(), "wrench");
|
||||
pipette = registerItem(new ItemPipette(), "pipette");
|
||||
@@ -170,8 +182,8 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
|
||||
// / RAINMAKER SUBSTRATES
|
||||
iodineCharge = registerItem(new ItemForestry(), "iodineCapsule");
|
||||
|
||||
phosphor = registerItem(new ItemForestry(), "phosphor");
|
||||
phosphorCharge = registerItem(new ItemForestry(), "phosphoricIodineCapsule");
|
||||
|
||||
// / BEE RESOURCES
|
||||
beeswax = registerItem(new ItemForestry(), "beeswax");
|
||||
@@ -187,4 +199,12 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
OreDictionary.registerOre(def.getOreDict(), fruit);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getAsh() {
|
||||
List<ItemStack> options = OreDictionary.getOres("dustAsh");
|
||||
for (ItemStack option : options) {
|
||||
if (option.getItem() != ash) return option.copy();
|
||||
}
|
||||
return ash.getItemStack();
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public enum PacketIdClient implements IPacketId {
|
||||
ITEMSTACK_DISPLAY,
|
||||
FX_SIGNAL,
|
||||
TANK_LEVEL_UPDATE,
|
||||
TILE_CONFIGURATION,
|
||||
|
||||
// Core Genome
|
||||
GENOME_TRACKER_UPDATE,
|
||||
|
||||
@@ -27,6 +27,7 @@ import forestry.core.network.packets.PacketPipetteClick;
|
||||
import forestry.core.network.packets.PacketSocketUpdate;
|
||||
import forestry.core.network.packets.PacketSolderingIronClick;
|
||||
import forestry.core.network.packets.PacketTankLevelUpdate;
|
||||
import forestry.core.network.packets.PacketTileConfiguration;
|
||||
import forestry.core.network.packets.PacketTileStream;
|
||||
|
||||
public class PacketRegistryCore extends PacketRegistry {
|
||||
@@ -47,6 +48,7 @@ public class PacketRegistryCore extends PacketRegistry {
|
||||
registerClientPacket(new PacketFXSignal());
|
||||
registerClientPacket(new PacketTankLevelUpdate());
|
||||
registerClientPacket(new PacketGenomeTrackerSync());
|
||||
registerClientPacket(new PacketTileConfiguration());
|
||||
|
||||
registerServerPacket(new PacketGuiSelectRequest());
|
||||
registerServerPacket(new PacketPipetteClick());
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package forestry.core.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IConfigurable;
|
||||
|
||||
/**
|
||||
* Used to sync the tile configuration from Server to Client.
|
||||
*/
|
||||
public class PacketTileConfiguration extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private TileEntity tileEntity = null;
|
||||
|
||||
public PacketTileConfiguration() {}
|
||||
|
||||
public PacketTileConfiguration(TileEntity tileEntity) {
|
||||
super(tileEntity);
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
if (tileEntity instanceof IConfigurable) {
|
||||
((IConfigurable) tileEntity).writeConfigurationData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IConfigurable) {
|
||||
((IConfigurable) tile).readConfigurationData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdClient getPacketId() {
|
||||
return PacketIdClient.TILE_CONFIGURATION;
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,10 @@ public class ProxyCommon {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isCtrlDown() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void playSoundFX(World world, int x, int y, int z, Block block) {
|
||||
Proxies.net.sendNetworkPacket(new PacketFXSignal(PacketFXSignal.SoundFXType.LEAF, x, y, z, block, 0), world);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ public class ProxyCommonClient extends ProxyCommon {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCtrlDown() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(ItemStack itemstack) {
|
||||
return itemstack.getItem().getItemStackDisplayName(itemstack);
|
||||
|
||||
@@ -112,15 +112,14 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
public List<String> handleTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, int recipe) {
|
||||
super.handleTooltip(guiRecipe, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
|
||||
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(
|
||||
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -131,12 +130,9 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(
|
||||
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
|
||||
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
|
||||
return currenttip;
|
||||
return this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
|
||||
}
|
||||
|
||||
public List<String> provideTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe,
|
||||
@@ -200,11 +196,9 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
|
||||
protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean usage) {
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mousepos = GuiDraw.getMousePosition();
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(
|
||||
mousepos.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mousepos.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
|
||||
|
||||
@@ -14,11 +14,15 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
// Seems to be set during registration - should be fine to not use a concurrent hashmap
|
||||
public static final HashMap<TileRendererIndex, IBlockRenderer> byBlockRenderer = new HashMap<>();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,8 +14,11 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public abstract class RenderOverlayBlock implements ISimpleBlockRenderingHandler {
|
||||
|
||||
protected static final double OVERLAY_SHIFT = 0.001;
|
||||
|
||||
@@ -51,7 +51,9 @@ public class TextureManager implements ITextureManager {
|
||||
"analyzer/nocturnal", "analyzer/princess", "analyzer/pure_breed", "analyzer/pure_cave",
|
||||
"analyzer/pure_flyer", "analyzer/pure_nocturnal", "analyzer/queen", "particles/swarm_bee",
|
||||
"errors/errored", "errors/unknown", "slots/blocked", "slots/blocked_2", "slots/liquid",
|
||||
"slots/container", "slots/locked", "mail/carrier.player", "mail/carrier.trader" };
|
||||
"slots/container", "slots/locked", "mail/carrier.player", "mail/carrier.trader",
|
||||
"misc/search_ingredients.internal_inventory", "misc/search_ingredients.player_inventory",
|
||||
"misc/search_ingredients.all_inventories" };
|
||||
for (String str : defaultIconNames) {
|
||||
IIcon icon = registerTex(register, str);
|
||||
defaultIcons.put(str, icon);
|
||||
|
||||
@@ -37,7 +37,8 @@ public class EscritoireTextSource {
|
||||
EnumSet<Notes> multipleTranslationNoteLevels = EnumSet
|
||||
.of(Notes.level1, Notes.level2, Notes.level3, Notes.level4, Notes.success, Notes.failure);
|
||||
for (Notes notesLevel : multipleTranslationNoteLevels) {
|
||||
int levelCount = Integer.valueOf(StringUtil.localize("gui.escritoire.notes." + notesLevel + ".count"));
|
||||
int levelCount = Integer.valueOf(
|
||||
StringUtil.localize("gui.escritoire.notes." + notesLevel + ".count").replaceAll("§\\d", ""));
|
||||
for (int i = 1; i <= levelCount; i++) {
|
||||
String note = StringUtil.localize("gui.escritoire.notes." + notesLevel + '.' + i);
|
||||
researchNotes.put(notesLevel, note);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public interface IConfigurable {
|
||||
|
||||
void writeConfigurationData(DataOutputStreamForestry data) throws IOException;
|
||||
|
||||
void readConfigurationData(DataInputStreamForestry data) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
public interface IIngredientsSearchController {
|
||||
|
||||
IngredientsStorage getIngredientsStorage();
|
||||
|
||||
void setIngredientsStorage(IngredientsStorage ingredientsStorage);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.inventory.MergedInventories;
|
||||
|
||||
public enum IngredientsStorage {
|
||||
|
||||
INTERNAL_INVENTORY,
|
||||
PLAYER_INVENTORY,
|
||||
ALL_INVENTORIES;
|
||||
|
||||
public static final IngredientsStorage[] VALUES = values();
|
||||
|
||||
public static IngredientsStorage fromInt(int value) {
|
||||
value = value % VALUES.length;
|
||||
if (value < 0) {
|
||||
value += VALUES.length;
|
||||
}
|
||||
return VALUES[value];
|
||||
}
|
||||
|
||||
public IngredientsStorage next() {
|
||||
return fromInt(ordinal() + 1);
|
||||
}
|
||||
|
||||
public IngredientsStorage previous() {
|
||||
return fromInt(ordinal() - 1);
|
||||
}
|
||||
|
||||
public IInventory getInventory(IInventory internal, EntityPlayer player) {
|
||||
switch (this) {
|
||||
case PLAYER_INVENTORY:
|
||||
return player.inventory;
|
||||
case ALL_INVENTORIES:
|
||||
return new MergedInventories(internal, player.inventory);
|
||||
default:
|
||||
return internal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,16 +241,16 @@ public abstract class BlockUtil {
|
||||
if (bw) try {
|
||||
// noinspection unchecked
|
||||
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class
|
||||
.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_WerkstoffBlocks");
|
||||
BWBlocks = (Block) Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader")
|
||||
.getField("BWBlocks").get(null);
|
||||
.forName("bartworks.system.material.BWMetaGeneratedWerkstoffBlocks");
|
||||
BWBlocks = (Block) Class.forName("bartworks.system.material.WerkstoffLoader").getField("BWBlocks")
|
||||
.get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (gt) try {
|
||||
// noinspection unchecked
|
||||
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.GT_Block_Machines");
|
||||
GTBlockMachines = (Block) Class.forName("gregtech.api.GregTech_API").getField("sBlockMachines").get(null);
|
||||
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.BlockMachines");
|
||||
GTBlockMachines = (Block) Class.forName("gregtech.api.GregTechAPI").getField("sBlockMachines").get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -96,6 +96,8 @@ public class GeneticsUtil {
|
||||
* altering the world by changing vanilla leaves to forestry ones.
|
||||
*/
|
||||
public static ICheckPollinatable getCheckPollinatable(World world, final int x, final int y, final int z) {
|
||||
if (!world.blockExists(x, y, z)) return null;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof IPollinatable) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class MathUtil {
|
||||
|
||||
private static final BigDecimal MAX_FLOAT = BigDecimal.valueOf(Float.MAX_VALUE);
|
||||
private static final BigDecimal MIN_FLOAT = BigDecimal.valueOf(-Float.MAX_VALUE);
|
||||
|
||||
private static float clampToFloatRange(BigDecimal result) {
|
||||
if (result.compareTo(MAX_FLOAT) > 0) {
|
||||
return Float.MAX_VALUE;
|
||||
} else if (result.compareTo(MIN_FLOAT) < 0) {
|
||||
return -Float.MAX_VALUE;
|
||||
}
|
||||
return result.floatValue();
|
||||
}
|
||||
|
||||
public static float safeMultiply(float a, float b) {
|
||||
BigDecimal bigA = BigDecimal.valueOf(a);
|
||||
BigDecimal bigB = BigDecimal.valueOf(b);
|
||||
return clampToFloatRange(bigA.multiply(bigB));
|
||||
}
|
||||
|
||||
public static float safeAdd(float a, float b) {
|
||||
BigDecimal bigA = BigDecimal.valueOf(a);
|
||||
BigDecimal bigB = BigDecimal.valueOf(b);
|
||||
return clampToFloatRange(bigA.add(bigB));
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import forestry.api.farming.FarmDirection;
|
||||
/**
|
||||
* Represents a position or dimensions.
|
||||
*/
|
||||
public interface IVect {
|
||||
public interface IVect extends Comparable<IVect> {
|
||||
|
||||
int getX();
|
||||
|
||||
@@ -34,5 +34,32 @@ public interface IVect {
|
||||
|
||||
IVect add(ChunkCoordinates coordinates);
|
||||
|
||||
IVect multiply(int factor);
|
||||
|
||||
IVect multiply(float factor);
|
||||
|
||||
int[] toArray();
|
||||
|
||||
Vect asImmutable();
|
||||
|
||||
MutableVect asMutable();
|
||||
|
||||
// NOTE: All classes implementing this must implement the same hashCode and equals methods as Vect
|
||||
int hashCode();
|
||||
|
||||
boolean equals(Object obj);
|
||||
|
||||
default int compareTo(IVect other) {
|
||||
int x = this.getX() - other.getX();
|
||||
if (x != 0) {
|
||||
return x;
|
||||
}
|
||||
|
||||
int y = this.getY() - other.getY();
|
||||
if (y != 0) {
|
||||
return y;
|
||||
}
|
||||
|
||||
return this.getZ() - other.getZ();
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ public class MutableVect implements IVect {
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
public MutableVect() {
|
||||
this(0, 0, 0);
|
||||
}
|
||||
|
||||
public MutableVect(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -96,7 +100,16 @@ public class MutableVect implements IVect {
|
||||
return new int[] { x, y, z };
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVect multiply(float factor) {
|
||||
this.x = Math.round(x * factor);
|
||||
this.y = Math.round(y * factor);
|
||||
this.z = Math.round(z * factor);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVect multiply(int factor) {
|
||||
this.x *= factor;
|
||||
this.y *= factor;
|
||||
this.z *= factor;
|
||||
@@ -140,4 +153,82 @@ public class MutableVect implements IVect {
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public MutableVect setX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect setY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect setZ(int z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect set(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect set(IVect vect) {
|
||||
this.x = vect.getX();
|
||||
this.y = vect.getY();
|
||||
this.z = vect.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect set(ChunkCoordinates coordinates) {
|
||||
this.x = coordinates.posX;
|
||||
this.y = coordinates.posY;
|
||||
this.z = coordinates.posZ;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect set(ForgeDirection direction) {
|
||||
this.x = direction.offsetX;
|
||||
this.y = direction.offsetY;
|
||||
this.z = direction.offsetZ;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect set(FarmDirection direction) {
|
||||
return set(direction.getForgeDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof IVect other) {
|
||||
return x == other.getX() && y == other.getY() && z == other.getZ();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect asImmutable() {
|
||||
return new Vect(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVect asMutable() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -73,9 +73,9 @@ public class Vect implements IVect {
|
||||
}
|
||||
|
||||
public static Vect getRandomPositionInArea(Random random, IVect area) {
|
||||
int x = random.nextInt(area.getX());
|
||||
int y = random.nextInt(area.getY());
|
||||
int z = random.nextInt(area.getZ());
|
||||
int x = random.nextInt(area.getX() + 1);
|
||||
int y = random.nextInt(area.getY() + 1);
|
||||
int z = random.nextInt(area.getZ() + 1);
|
||||
return new Vect(x, y, z);
|
||||
}
|
||||
|
||||
@@ -121,10 +121,12 @@ public class Vect implements IVect {
|
||||
return new int[] { x, y, z };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect multiply(int factor) {
|
||||
return new Vect(x * factor, y * factor, z * factor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect multiply(float factor) {
|
||||
return new Vect(Math.round(x * factor), Math.round(y * factor), Math.round(z * factor));
|
||||
}
|
||||
@@ -149,11 +151,10 @@ public class Vect implements IVect {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Vect)) {
|
||||
return false;
|
||||
if ((obj instanceof IVect other)) {
|
||||
return (x == other.getX()) && (y == other.getY()) && (z == other.getZ());
|
||||
}
|
||||
Vect other = (Vect) obj;
|
||||
return (x == other.x) && (y == other.y) && (z == other.z);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,4 +171,15 @@ public class Vect implements IVect {
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect asImmutable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVect asMutable() {
|
||||
return new MutableVect(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory {
|
||||
return i;
|
||||
}
|
||||
|
||||
if (waste.getItem() != PluginCore.items.ash) {
|
||||
if (waste.getItem() != PluginCore.items.getAsh().getItem()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory {
|
||||
if (wasteSlot >= 0) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(wasteSlot) == null) {
|
||||
inventory.setInventorySlotContents(wasteSlot, PluginCore.items.ash.getItemStack());
|
||||
inventory.setInventorySlotContents(wasteSlot, PluginCore.items.getAsh());
|
||||
} else {
|
||||
inventory.getStackInSlot(wasteSlot).stackSize++;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import forestry.core.gui.slots.SlotCraftMatrix;
|
||||
import forestry.core.gui.slots.SlotCrafter;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IngredientsStorage;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.factory.inventory.InventoryCraftingForestry;
|
||||
@@ -207,6 +208,15 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
|
||||
sendPacketToCrafters(new PacketWorktableRecipeUpdate(tile));
|
||||
break;
|
||||
}
|
||||
case 200: { // switch ingredients storage
|
||||
tile.setIngredientsStorage(IngredientsStorage.fromInt(secondary));
|
||||
markConfigurationDirty();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IngredientsStorage getIngredientsStorage() {
|
||||
return tile.getIngredientsStorage();
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,12 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.buttons.GuiBetterButton;
|
||||
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
||||
import forestry.core.gui.ledgers.SearchIngregientsLedger;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.tiles.IIngredientsSearchController;
|
||||
import forestry.core.tiles.IngredientsStorage;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.factory.gui.widgets.ClearWorktable;
|
||||
import forestry.factory.gui.widgets.MemorizedRecipeSlot;
|
||||
@@ -30,13 +33,16 @@ import forestry.factory.recipes.MemorizedRecipe;
|
||||
import forestry.factory.recipes.RecipeMemory;
|
||||
import forestry.factory.tiles.TileWorktable;
|
||||
|
||||
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable> {
|
||||
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable>
|
||||
implements IIngredientsSearchController {
|
||||
|
||||
private static final int SPACING = 18;
|
||||
private boolean hasRecipeConflict = false;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public GuiWorktable(EntityPlayer player, TileWorktable tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/worktable2.png", new ContainerWorktable(player, tile), tile);
|
||||
this.player = player;
|
||||
|
||||
ySize = 218;
|
||||
|
||||
@@ -60,6 +66,12 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
widgetManager.add(new ClearWorktable(widgetManager, 66, 19));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLedgers() {
|
||||
super.addLedgers();
|
||||
ledgerManager.add(new SearchIngregientsLedger(ledgerManager, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
@@ -82,7 +94,7 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
.get(54 + InventoryGhostCrafting.SLOT_CRAFTING_RESULT);
|
||||
|
||||
if (func_146978_c(itemSlot.xDisplayPosition, itemSlot.yDisplayPosition, 16, 16, mouseX, mouseY)
|
||||
&& !inventory.canTakeStack(InventoryGhostCrafting.SLOT_CRAFTING_RESULT)) {
|
||||
&& !inventory.canTakeStack(player, InventoryGhostCrafting.SLOT_CRAFTING_RESULT)) {
|
||||
final MemorizedRecipe recipe = inventory.getCurrentRecipe();
|
||||
|
||||
if (recipe != null) {
|
||||
@@ -121,4 +133,14 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
int id = 100 + button.id;
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(id, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IngredientsStorage getIngredientsStorage() {
|
||||
return container.getIngredientsStorage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredientsStorage(IngredientsStorage ingredientsStorage) {
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(200, ingredientsStorage.ordinal()));
|
||||
}
|
||||
}
|
||||
@@ -26,16 +26,14 @@ public class InventoryRainmaker extends InventoryAdapterTile<TileMillRainmaker>
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_SUBSTRATE) {
|
||||
if (getStackInSlot(SLOT_SUBSTRATE) != null) {
|
||||
return false;
|
||||
}
|
||||
if (FuelManager.rainSubstrate.containsKey(itemStack) && tile.charge == 0 && tile.progress == 0) {
|
||||
RainSubstrate substrate = FuelManager.rainSubstrate.get(itemStack);
|
||||
if (tile.getWorld().isRaining() && substrate.reverse) {
|
||||
return true;
|
||||
} else if (!tile.getWorld().isRaining() && !substrate.reverse) {
|
||||
return true;
|
||||
}
|
||||
return tile.isValidSubstrate(substrate);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ public interface ICrafterWorktable {
|
||||
|
||||
ItemStack getResult();
|
||||
|
||||
boolean canTakeStack(int slotIndex);
|
||||
boolean canTakeStack(EntityPlayer player, int slotIndex);
|
||||
|
||||
boolean onCraftingStart(EntityPlayer player);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package forestry.factory.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.RainSubstrate;
|
||||
@@ -20,7 +21,7 @@ import forestry.factory.inventory.InventoryRainmaker;
|
||||
public class TileMillRainmaker extends TileMill {
|
||||
|
||||
private int duration;
|
||||
private boolean reverse;
|
||||
private RainSubstrate.WeatherState weather;
|
||||
|
||||
public TileMillRainmaker() {
|
||||
super(null);
|
||||
@@ -39,9 +40,9 @@ public class TileMillRainmaker extends TileMill {
|
||||
}
|
||||
|
||||
// We don't have a gui, but we can be activated
|
||||
if (FuelManager.rainSubstrate.containsKey(player.inventory.getCurrentItem()) && charge == 0) {
|
||||
if (FuelManager.rainSubstrate.containsKey(player.inventory.getCurrentItem()) && charge == 0 && progress == 0) {
|
||||
RainSubstrate substrate = FuelManager.rainSubstrate.get(player.inventory.getCurrentItem());
|
||||
if (substrate.item.isItemEqual(player.inventory.getCurrentItem())) {
|
||||
if (isValidSubstrate(substrate)) {
|
||||
addCharge(substrate);
|
||||
player.inventory.getCurrentItem().stackSize--;
|
||||
}
|
||||
@@ -49,6 +50,17 @@ public class TileMillRainmaker extends TileMill {
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
|
||||
public boolean isValidSubstrate(RainSubstrate substrate) {
|
||||
boolean thundering = getWorld().isThundering();
|
||||
boolean raining = getWorld().isRaining();
|
||||
|
||||
return switch (substrate.weather) {
|
||||
case CLEAR -> (thundering || raining);
|
||||
case RAIN -> (thundering || !raining);
|
||||
case STORM -> (!thundering);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
@@ -57,7 +69,7 @@ public class TileMillRainmaker extends TileMill {
|
||||
progress = nbttagcompound.getFloat("Progress");
|
||||
stage = nbttagcompound.getInteger("Stage");
|
||||
duration = nbttagcompound.getInteger("Duration");
|
||||
reverse = nbttagcompound.getBoolean("Reverse");
|
||||
weather = RainSubstrate.WeatherState.valueOf(nbttagcompound.getString("Weather"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,14 +80,14 @@ public class TileMillRainmaker extends TileMill {
|
||||
nbttagcompound.setFloat("Progress", progress);
|
||||
nbttagcompound.setInteger("Stage", stage);
|
||||
nbttagcompound.setInteger("Duration", duration);
|
||||
nbttagcompound.setBoolean("Reverse", reverse);
|
||||
nbttagcompound.setString("Weather", weather.name());
|
||||
}
|
||||
|
||||
public void addCharge(RainSubstrate substrate) {
|
||||
charge = 1;
|
||||
speed = substrate.speed;
|
||||
duration = substrate.duration;
|
||||
reverse = substrate.reverse;
|
||||
weather = substrate.weather;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
|
||||
@@ -103,15 +115,26 @@ public class TileMillRainmaker extends TileMill {
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
if (reverse) {
|
||||
worldObj.getWorldInfo().setRaining(false);
|
||||
} else {
|
||||
worldObj.getWorldInfo().setRaining(true);
|
||||
worldObj.getWorldInfo().setRainTime(duration);
|
||||
WorldInfo world = worldObj.getWorldInfo();
|
||||
switch (weather) {
|
||||
case CLEAR:
|
||||
world.setRaining(false);
|
||||
world.setThundering(false);
|
||||
break;
|
||||
case STORM:
|
||||
world.setRaining(true);
|
||||
world.setRainTime(duration);
|
||||
world.setThundering(true);
|
||||
world.setThunderTime(duration);
|
||||
break;
|
||||
case RAIN:
|
||||
world.setRaining(true);
|
||||
world.setRainTime(duration);
|
||||
world.setThundering(false);
|
||||
break;
|
||||
}
|
||||
charge = 0;
|
||||
duration = 0;
|
||||
reverse = false;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import forestry.core.inventory.wrappers.InventoryMapper;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.tiles.IConfigurable;
|
||||
import forestry.core.tiles.IngredientsStorage;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
@@ -35,13 +37,14 @@ import forestry.factory.inventory.InventoryWorktable;
|
||||
import forestry.factory.recipes.MemorizedRecipe;
|
||||
import forestry.factory.recipes.RecipeMemory;
|
||||
|
||||
public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
public class TileWorktable extends TileBase implements ICrafterWorktable, IConfigurable {
|
||||
|
||||
private final RecipeMemory recipeMemory;
|
||||
private final InventoryAdapterTile<?> craftingDisplay;
|
||||
private MemorizedRecipe currentRecipe;
|
||||
private long savedTick = 0;
|
||||
private long savedSystemTimeExpiration = 0;
|
||||
private IngredientsStorage ingredientsStorage = IngredientsStorage.INTERNAL_INVENTORY;
|
||||
|
||||
public TileWorktable() {
|
||||
super("worktable");
|
||||
@@ -58,6 +61,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
|
||||
craftingDisplay.writeToNBT(nbttagcompound);
|
||||
recipeMemory.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("IngredientsStorage", ingredientsStorage.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,6 +70,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
|
||||
craftingDisplay.readFromNBT(nbttagcompound);
|
||||
recipeMemory.readFromNBT(nbttagcompound);
|
||||
ingredientsStorage = IngredientsStorage.fromInt(nbttagcompound.getInteger("IngredientsStorage"));
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@@ -108,16 +113,20 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
}
|
||||
}
|
||||
|
||||
private IInventory getIngredientsInventory(EntityPlayer player) {
|
||||
return ingredientsStorage.getInventory(this, player);
|
||||
}
|
||||
|
||||
/* ICrafterWorktable */
|
||||
@Override
|
||||
public boolean canTakeStack(int craftingSlotIndex) {
|
||||
public boolean canTakeStack(EntityPlayer player, int craftingSlotIndex) {
|
||||
if (craftingSlotIndex == InventoryGhostCrafting.SLOT_CRAFTING_RESULT) {
|
||||
return canCraftCurrentRecipe();
|
||||
return canCraftCurrentRecipe(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canCraftCurrentRecipe() {
|
||||
private boolean canCraftCurrentRecipe(EntityPlayer player) {
|
||||
if (currentRecipe == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -139,7 +148,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
}
|
||||
|
||||
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||
ItemStack[] inventory = InventoryUtil.getStacks(this);
|
||||
ItemStack[] inventory = InventoryUtil.getStacks(getIngredientsInventory(player));
|
||||
InventoryCraftingForestry crafting = RecipeUtil
|
||||
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
||||
|
||||
@@ -152,8 +161,9 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
return false;
|
||||
}
|
||||
|
||||
IInventory ingredientsInventory = getIngredientsInventory(player);
|
||||
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||
ItemStack[] inventory = InventoryUtil.getStacks(this);
|
||||
ItemStack[] inventory = InventoryUtil.getStacks(ingredientsInventory);
|
||||
InventoryCraftingForestry crafting = RecipeUtil
|
||||
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
||||
if (crafting == null) {
|
||||
@@ -163,7 +173,8 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
recipeItems = InventoryUtil.getStacks(crafting);
|
||||
|
||||
// craft recipe should exactly match ingredients here, so no oreDict or tool matching
|
||||
ItemStack[] removed = InventoryUtil.removeSets(this, 1, recipeItems, player, false, false, false);
|
||||
ItemStack[] removed = InventoryUtil
|
||||
.removeSets(ingredientsInventory, 1, recipeItems, player, false, false, false);
|
||||
if (removed == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -175,6 +186,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
@Override
|
||||
public void onCraftingComplete(EntityPlayer player) {
|
||||
IInventory craftingInventory = getCraftingDisplay();
|
||||
IInventory ingredientsInventory = getIngredientsInventory(player);
|
||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
||||
ItemStack itemStack = craftingInventory.getStackInSlot(i);
|
||||
if (itemStack == null) {
|
||||
@@ -202,7 +214,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!InventoryUtil.tryAddStack(this, container, true)) {
|
||||
if (!InventoryUtil.tryAddStack(ingredientsInventory, container, true)) {
|
||||
player.dropPlayerItemWithRandomChoice(container, false);
|
||||
}
|
||||
}
|
||||
@@ -287,6 +299,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
}
|
||||
}
|
||||
|
||||
public IngredientsStorage getIngredientsStorage() {
|
||||
return ingredientsStorage;
|
||||
}
|
||||
|
||||
public void setIngredientsStorage(IngredientsStorage ingredientsStorage) {
|
||||
this.ingredientsStorage = ingredientsStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return new GuiWorktable(player, this);
|
||||
@@ -296,4 +316,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerWorktable(player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfigurationData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeEnum(ingredientsStorage, IngredientsStorage.VALUES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfigurationData(DataInputStreamForestry data) throws IOException {
|
||||
ingredientsStorage = data.readEnum(IngredientsStorage.VALUES);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public abstract class Crop implements ICrop {
|
||||
@@ -28,21 +29,21 @@ public abstract class Crop implements ICrop {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
protected final void setBlock(Vect position, Block block, int meta) {
|
||||
world.setBlock(position.x, position.y, position.z, block, meta, Constants.FLAG_BLOCK_SYNCH);
|
||||
protected final void setBlock(IVect position, Block block, int meta) {
|
||||
world.setBlock(position.getX(), position.getY(), position.getZ(), block, meta, Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
protected final Block getBlock(Vect position) {
|
||||
return world.getBlock(position.x, position.y, position.z);
|
||||
protected final Block getBlock(IVect position) {
|
||||
return world.getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected final int getBlockMeta(Vect position) {
|
||||
return world.getBlockMetadata(position.x, position.y, position.z);
|
||||
protected final int getBlockMeta(IVect position) {
|
||||
return world.getBlockMetadata(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected abstract boolean isCrop(Vect pos);
|
||||
protected abstract boolean isCrop(IVect pos);
|
||||
|
||||
protected abstract Collection<ItemStack> harvestBlock(Vect pos);
|
||||
protected abstract Collection<ItemStack> harvestBlock(IVect pos);
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> harvest() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class CropBasicAgriCraft extends Crop {
|
||||
@@ -33,21 +34,21 @@ public class CropBasicAgriCraft extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
return getBlock(pos) == block && getBlockMeta(pos) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
ArrayList<ItemStack> harvest = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
ArrayList<ItemStack> harvest = block.getDrops(world, pos.getX(), pos.getY(), pos.getZ(), meta, 0);
|
||||
if (harvest.size() > 1) {
|
||||
harvest.remove(1); // AgriCraft returns cropsticks in 0, seeds in 1 in getDrops, removing since harvesting
|
||||
// doesn't
|
||||
// return them.
|
||||
}
|
||||
harvest.remove(0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, Blocks.melon_block, 0);
|
||||
world.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.getX(), pos.getY(), pos.getZ(), Blocks.melon_block, 0);
|
||||
world.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
harvest.removeAll(Collections.singleton(null)); // sanatize nulls that get thru from Agricraft+Harvestcraft
|
||||
// (sesameseed)
|
||||
return harvest;
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class CropBasicFruit extends Crop {
|
||||
@@ -30,15 +31,15 @@ public class CropBasicFruit extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
return getBlock(pos) == block && getBlockMeta(pos) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
Collection<ItemStack> harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
|
||||
world.setBlock(pos.x, pos.y, pos.z, block, 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
Collection<ItemStack> harvested = block.getDrops(world, pos.getX(), pos.getY(), pos.getZ(), meta, 0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.getX(), pos.getY(), pos.getZ(), block, 0);
|
||||
world.setBlock(pos.getX(), pos.getY(), pos.getZ(), block, 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
return harvested;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class CropBasicGrowthCraft extends Crop {
|
||||
@@ -35,26 +36,26 @@ public class CropBasicGrowthCraft extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
return getBlock(pos) == block && getBlockMeta(pos) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
ArrayList<ItemStack> harvest = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
ArrayList<ItemStack> harvest = block.getDrops(world, pos.getX(), pos.getY(), pos.getZ(), meta, 0);
|
||||
if (harvest.size() > 1) {
|
||||
harvest.remove(0); // Hops have rope as first drop.
|
||||
}
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.getX(), pos.getY(), pos.getZ(), block, 0);
|
||||
if (isGrape) {
|
||||
world.setBlockToAir(pos.x, pos.y, pos.z);
|
||||
world.setBlockToAir(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
} else {
|
||||
world.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
world.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), 0, Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
if (isRice) {
|
||||
world.setBlockMetadataWithNotify(pos.x, pos.y - 1, pos.z, 7, Constants.FLAG_BLOCK_SYNCH);
|
||||
world.setBlockMetadataWithNotify(pos.getX(), pos.getY() - 1, pos.getZ(), 7, Constants.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
return harvest;
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
@@ -19,12 +20,12 @@ public class CropBasicIC2Crop extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
return PluginIC2.instance.canHarvestCrop(this.tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
return PluginIC2.instance.getCropDrops(this.tileEntity);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class CropBlock extends Crop {
|
||||
@@ -29,16 +30,16 @@ public class CropBlock extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
return getBlock(pos) == block && getBlockMeta(pos) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
Collection<ItemStack> harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
Collection<ItemStack> harvested = block.getDrops(world, pos.getX(), pos.getY(), pos.getZ(), meta, 0);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.getX(), pos.getY(), pos.getZ(), block, 0);
|
||||
// Block.breakBlock() is called by vanilla itself, removing TEs.
|
||||
world.setBlockToAir(pos.x, pos.y, pos.z);
|
||||
world.setBlockToAir(pos.getX(), pos.getY(), pos.getZ());
|
||||
return harvested;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.world.World;
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class CropFruit extends Crop {
|
||||
@@ -27,8 +28,8 @@ public class CropFruit extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z);
|
||||
protected boolean isCrop(IVect pos) {
|
||||
TileEntity tile = world.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
if (!(tile instanceof IFruitBearer)) {
|
||||
return false;
|
||||
}
|
||||
@@ -44,8 +45,8 @@ public class CropFruit extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z);
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
TileEntity tile = world.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
if (!(tile instanceof IFruitBearer)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -54,10 +55,10 @@ public class CropFruit extends Crop {
|
||||
PacketFXSignal.VisualFXType.BLOCK_DESTROY,
|
||||
PacketFXSignal.SoundFXType.LEAF,
|
||||
world,
|
||||
pos.x,
|
||||
pos.y,
|
||||
pos.z,
|
||||
world.getBlock(pos.x, pos.y, pos.z),
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ(),
|
||||
world.getBlock(pos.getX(), pos.getY(), pos.getZ()),
|
||||
0);
|
||||
return ((IFruitBearer) tile).pickFruit(null);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.blocks.BlockSoil;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.PluginCore;
|
||||
|
||||
@@ -29,7 +30,7 @@ public class CropPeat extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
protected boolean isCrop(IVect pos) {
|
||||
Block block = getBlock(pos);
|
||||
if (!(block instanceof BlockSoil)) {
|
||||
return false;
|
||||
@@ -41,11 +42,17 @@ public class CropPeat extends Crop {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add(PluginCore.items.peat.getItemStack());
|
||||
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, world.getBlock(pos.x, pos.y, pos.z), 0);
|
||||
Proxies.common.addBlockDestroyEffects(
|
||||
world,
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ(),
|
||||
world.getBlock(pos.getX(), pos.getY(), pos.getZ()),
|
||||
0);
|
||||
setBlock(pos, Blocks.dirt, 0);
|
||||
return drops;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
@@ -27,11 +28,11 @@ public class CropRubber extends CropBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
protected Collection<ItemStack> harvestBlock(IVect pos) {
|
||||
Collection<ItemStack> harvested = new ArrayList<>();
|
||||
harvested.add(PluginIC2.resin.copy());
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
|
||||
world.setBlock(pos.x, pos.y, pos.z, block, meta + 6, Constants.FLAG_BLOCK_SYNCH);
|
||||
Proxies.common.addBlockDestroyEffects(world, pos.getX(), pos.getY(), pos.getZ(), block, 0);
|
||||
world.setBlock(pos.getX(), pos.getY(), pos.getZ(), block, meta + 6, Constants.FLAG_BLOCK_SYNCH);
|
||||
return harvested;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.entities.EntitySelector;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.EntityUtil;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
@@ -64,8 +65,10 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
&& world.getBlockMetadata(position.x, position.y, position.z) == 0;
|
||||
}
|
||||
|
||||
protected final MutableVect mutableVect = new MutableVect();
|
||||
|
||||
protected final Vect translateWithOffset(int x, int y, int z, FarmDirection farmDirection, int step) {
|
||||
return new Vect(farmDirection.getForgeDirection()).multiply(step).add(x, y, z);
|
||||
return new Vect(mutableVect.set(farmDirection.getForgeDirection()).multiply(step).add(x, y, z));
|
||||
}
|
||||
|
||||
protected final void setBlock(Vect position, Block block, int meta) {
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -32,6 +33,7 @@ import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.blocks.BlockSoil;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
import forestry.plugins.PluginCore;
|
||||
@@ -128,7 +130,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
|
||||
World world = getWorld();
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
|
||||
// Determine what type we want to harvest.
|
||||
IFarmable germling = null;
|
||||
@@ -162,7 +164,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
|
||||
return crops;
|
||||
}
|
||||
|
||||
private ArrayList<Vect> processHarvestBlock(IFarmable germling, Stack<ICrop> crops, Set<Vect> seen, Vect start,
|
||||
private ArrayList<Vect> processHarvestBlock(IFarmable germling, Deque<ICrop> crops, Set<Vect> seen, Vect start,
|
||||
Vect position) {
|
||||
|
||||
World world = getWorld();
|
||||
@@ -170,30 +172,32 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
|
||||
ArrayList<Vect> candidates = new ArrayList<>();
|
||||
|
||||
// Get additional candidates to return
|
||||
MutableVect mutable = new MutableVect();
|
||||
for (int x = -1; x < 2; x++) {
|
||||
for (int y = -1; y < 2; y++) {
|
||||
for (int z = -1; z < 2; z++) {
|
||||
Vect candidate = position.add(x, y, z);
|
||||
if (candidate.equals(position)) {
|
||||
mutable.set(position).add(x, y, z);
|
||||
if (mutable.equals(position)) {
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(candidate.x - start.x) > BRANCH_RANGE) {
|
||||
if (Math.abs(mutable.x - start.x) > BRANCH_RANGE) {
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(candidate.z - start.z) > BRANCH_RANGE) {
|
||||
if (Math.abs(mutable.z - start.z) > BRANCH_RANGE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
if (seen.contains(mutable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ICrop crop = germling.getCropAt(world, candidate.x, candidate.y, candidate.z);
|
||||
ICrop crop = germling.getCropAt(world, mutable.x, mutable.y, mutable.z);
|
||||
if (crop != null) {
|
||||
Vect immutable = mutable.asImmutable();
|
||||
crops.push(crop);
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLog;
|
||||
@@ -29,6 +30,7 @@ import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
@@ -160,7 +162,7 @@ public class FarmLogicCocoa extends FarmLogic {
|
||||
private Collection<ICrop> getHarvestBlocks(Vect position) {
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
|
||||
// Determine what type we want to harvest.
|
||||
Block block = VectUtil.getBlock(getWorld(), position);
|
||||
@@ -193,40 +195,43 @@ public class FarmLogicCocoa extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
|
||||
private ArrayList<Vect> processHarvestBlock(Deque<ICrop> crops, Set<Vect> seen, Vect start, IVect position) {
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
ArrayList<Vect> candidates = new ArrayList<>();
|
||||
|
||||
// Get additional candidates to return
|
||||
MutableVect mutable = new MutableVect();
|
||||
for (int i = -1; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = -1; k < 2; k++) {
|
||||
Vect candidate = position.add(i, j, k);
|
||||
if (candidate.equals(position)) {
|
||||
mutable.set(position).add(i, j, k);
|
||||
if (mutable.equals(position)) {
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(candidate.x - start.x) > 5) {
|
||||
if (Math.abs(mutable.x - start.x) > 5) {
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(candidate.z - start.z) > 5) {
|
||||
if (Math.abs(mutable.z - start.z) > 5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
if (seen.contains(mutable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ICrop crop = cocoa.getCropAt(world, candidate.x, candidate.y, candidate.z);
|
||||
ICrop crop = cocoa.getCropAt(world, mutable.x, mutable.y, mutable.z);
|
||||
if (crop != null) {
|
||||
Vect immutable = mutable.asImmutable();
|
||||
crops.push(crop);
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
} else if (VectUtil.isWoodBlock(world, candidate)) {
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
} else if (VectUtil.isWoodBlock(world, mutable)) {
|
||||
Vect immutable = mutable.asImmutable();
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -111,7 +112,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable seed : seeds) {
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -68,7 +69,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable farmable : germlings) {
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -85,7 +86,7 @@ public class FarmLogicGourd extends FarmLogic {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable seed : seeds) {
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -68,7 +69,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable farmable : germlings) {
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -35,6 +36,8 @@ import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.farming.IFarmableBasic;
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.core.utils.vect.IVect;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
import forestry.plugins.PluginCore;
|
||||
@@ -145,7 +148,7 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
private Collection<ICrop> getHarvestBlocks(Vect position) {
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
@@ -158,8 +161,8 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
List<Vect> candidates = processHarvestBlock(crops, seen, position, position);
|
||||
List<Vect> temp = new ArrayList<>();
|
||||
while (!candidates.isEmpty() && crops.size() < 20) {
|
||||
for (Vect candidate : candidates) {
|
||||
temp.addAll(processHarvestBlock(crops, seen, position, candidate));
|
||||
for (int i = 0; i < candidates.size(); i++) {
|
||||
temp.addAll(processHarvestBlock(crops, seen, position, candidates.get(i)));
|
||||
}
|
||||
candidates.clear();
|
||||
candidates.addAll(temp);
|
||||
@@ -169,39 +172,41 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
private List<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
|
||||
private List<Vect> processHarvestBlock(Deque<ICrop> crops, Set<Vect> seen, IVect start, IVect position) {
|
||||
World world = getWorld();
|
||||
|
||||
List<Vect> candidates = new ArrayList<>();
|
||||
|
||||
final MutableVect mutable = new MutableVect();
|
||||
// Get additional candidates to return
|
||||
for (int i = -2; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = -1; k < 2; k++) {
|
||||
Vect candidate = position.add(i, j, k);
|
||||
if (Math.abs(candidate.x - start.x) > 5) {
|
||||
mutable.set(position).add(i, j, k);
|
||||
if (Math.abs(mutable.getX() - start.getX()) > 5) {
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(candidate.z - start.z) > 5) {
|
||||
if (Math.abs(mutable.getZ() - start.getZ()) > 5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
if (seen.contains(mutable)) {
|
||||
continue;
|
||||
}
|
||||
if (VectUtil.isAirBlock(world, candidate)) {
|
||||
if (VectUtil.isAirBlock(world, mutable)) {
|
||||
continue;
|
||||
}
|
||||
if (VectUtil.isWoodBlock(world, candidate)
|
||||
|| isBlockTraversable(world, candidate, traversalBlocks)) {
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
} else if (isFruitBearer(world, candidate)) {
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
if (VectUtil.isWoodBlock(world, mutable) || isBlockTraversable(world, mutable, traversalBlocks)) {
|
||||
final Vect immutable = new Vect(mutable);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
} else if (isFruitBearer(world, mutable)) {
|
||||
final Vect immutable = new Vect(mutable);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
|
||||
ICrop crop = getCrop(world, candidate);
|
||||
ICrop crop = getCrop(world, immutable);
|
||||
if (crop != null) {
|
||||
crops.push(crop);
|
||||
}
|
||||
@@ -213,20 +218,20 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private boolean isFruitBearer(World world, Vect position) {
|
||||
private boolean isFruitBearer(World world, IVect position) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
|
||||
TileEntity tile = world.getTileEntity(position.getX(), position.getY(), position.getZ());
|
||||
if (tile instanceof IFruitBearer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Block block = precalcBlockType ? world.getBlock(position.x, position.y, position.z) : null;
|
||||
int meta = precalcBlockMeta ? world.getBlockMetadata(position.x, position.y, position.z) : -1;
|
||||
Block block = precalcBlockType ? world.getBlock(position.getX(), position.getY(), position.getZ()) : null;
|
||||
int meta = precalcBlockMeta ? world.getBlockMetadata(position.getX(), position.getY(), position.getZ()) : -1;
|
||||
|
||||
for (IFarmable farmable : farmables) {
|
||||
if (farmable instanceof IFarmableBasic) {
|
||||
if (((IFarmableBasic) farmable).isSapling(block, meta)) return true;
|
||||
} else if (farmable.isSaplingAt(world, position.x, position.y, position.z)) {
|
||||
} else if (farmable.isSaplingAt(world, position.getX(), position.getY(), position.getZ())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -234,29 +239,28 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isBlockTraversable(World world, Vect position, ImmutableList<Block> traversalBlocks) {
|
||||
private static boolean isBlockTraversable(World world, IVect position, ImmutableList<Block> traversalBlocks) {
|
||||
|
||||
Block candidate = VectUtil.getBlock(world, position);
|
||||
for (Block block : traversalBlocks) {
|
||||
if (block == (candidate)) {
|
||||
for (int i = 0; i < traversalBlocks.size(); i++) {
|
||||
if (candidate == traversalBlocks.get(i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ICrop getCrop(World world, Vect position) {
|
||||
private ICrop getCrop(World world, IVect position) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
|
||||
TileEntity tile = world.getTileEntity(position.getX(), position.getY(), position.getZ());
|
||||
|
||||
if (tile instanceof IFruitBearer) {
|
||||
IFruitBearer fruitBearer = (IFruitBearer) tile;
|
||||
if (tile instanceof IFruitBearer fruitBearer) {
|
||||
if (fruitBearer.hasFruit() && fruitBearer.getRipeness() >= 0.9f) {
|
||||
return new CropFruit(world, position);
|
||||
return new CropFruit(world, position.asImmutable());
|
||||
}
|
||||
} else {
|
||||
for (IFarmable seed : farmables) {
|
||||
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
|
||||
ICrop crop = seed.getCropAt(world, position.getX(), position.getY(), position.getZ());
|
||||
if (crop != null) {
|
||||
return crop;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -77,7 +78,7 @@ public class FarmLogicPeat extends FarmLogicWatered {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y, z, direction, i);
|
||||
ItemStack occupant = VectUtil.getAsItemStack(world, position);
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -99,7 +100,7 @@ public class FarmLogicReeds extends FarmLogic {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable seed : germlings) {
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -28,6 +29,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
@@ -123,7 +125,7 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
private Collection<ICrop> getHarvestBlocks(Vect position) {
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
@@ -152,31 +154,33 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect position) {
|
||||
private ArrayList<Vect> processHarvestBlock(Deque<ICrop> crops, Set<Vect> seen, Vect position) {
|
||||
World world = getWorld();
|
||||
|
||||
ArrayList<Vect> candidates = new ArrayList<>();
|
||||
|
||||
// Get additional candidates to return
|
||||
final MutableVect mutable = position.asMutable();
|
||||
for (int j = 0; j < 2; j++) {
|
||||
Vect candidate = new Vect(position.x, position.y + j, position.z);
|
||||
if (candidate.equals(position)) {
|
||||
mutable.y = position.y + j;
|
||||
if (mutable.equals(position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
if (seen.contains(mutable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = VectUtil.getBlock(world, candidate);
|
||||
Block block = VectUtil.getBlock(world, mutable);
|
||||
if (ItemStackUtil.equals(block, PluginIC2.rubberwood)) {
|
||||
int meta = VectUtil.getBlockMeta(world, candidate);
|
||||
final Vect immutable = new Vect(mutable);
|
||||
int meta = VectUtil.getBlockMeta(world, immutable);
|
||||
if (meta >= 2 && meta <= 5) {
|
||||
crops.push(new CropRubber(world, block, meta, candidate));
|
||||
crops.push(new CropRubber(world, block, meta, immutable));
|
||||
}
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
candidates.add(immutable);
|
||||
seen.add(immutable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -99,7 +100,7 @@ public class FarmLogicSucculent extends FarmLogic {
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
World world = getWorld();
|
||||
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
Deque<ICrop> crops = new ArrayDeque<>();
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
||||
for (IFarmable seed : germlings) {
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
package forestry.farming.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -110,8 +111,8 @@ public class FarmController extends RectangularMultiblockControllerBase
|
||||
private int allowedExtent = 0;
|
||||
|
||||
private IFarmLogic harvestProvider; // The farm logic which supplied the pending crops.
|
||||
private final Stack<ICrop> pendingCrops = new Stack<>();
|
||||
private final Stack<ItemStack> pendingProduce = new Stack<>();
|
||||
private final Deque<ICrop> pendingCrops = new ArrayDeque<>();
|
||||
private final Deque<ItemStack> pendingProduce = new ArrayDeque<>();
|
||||
|
||||
private Stage stage = Stage.CULTIVATE;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.multiblock;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.Deque;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -208,7 +208,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
produce.stackSize -= InventoryUtil.addStack(productInventory, produce, true);
|
||||
}
|
||||
|
||||
public void stowHarvest(Iterable<ItemStack> harvested, Stack<ItemStack> pendingProduce) {
|
||||
public void stowHarvest(Iterable<ItemStack> harvested, Deque<ItemStack> pendingProduce) {
|
||||
for (ItemStack harvest : harvested) {
|
||||
if (harvest == null) {
|
||||
continue;
|
||||
@@ -232,7 +232,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tryAddPendingProduce(Stack<ItemStack> pendingProduce) {
|
||||
public boolean tryAddPendingProduce(Deque<ItemStack> pendingProduce) {
|
||||
IInventory productInventory = getProductInventory();
|
||||
|
||||
ItemStack next = pendingProduce.peek();
|
||||
|
||||
@@ -12,10 +12,13 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
|
||||
import forestry.core.render.RenderOverlayBlock;
|
||||
import forestry.farming.blocks.BlockFarm;
|
||||
import forestry.plugins.PluginFarming;
|
||||
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class RenderFarmBlock extends RenderOverlayBlock {
|
||||
|
||||
@Override
|
||||
@@ -41,78 +44,14 @@ public class RenderFarmBlock extends RenderOverlayBlock {
|
||||
float adjG = 0.5f;
|
||||
float adjB = 0.5f;
|
||||
|
||||
renderBottomFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(0, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
renderTopFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(1, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
renderEastFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(2, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
renderWestFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(3, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
renderNorthFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(4, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
renderSouthFace(
|
||||
world,
|
||||
block,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
renderer,
|
||||
BlockFarm.getOverlayTextureForBlock(5, metadata),
|
||||
mixedBrightness,
|
||||
adjR,
|
||||
adjG,
|
||||
adjB);
|
||||
// spotless:off
|
||||
renderBottomFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(0, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
renderTopFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(1, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
renderEastFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(2, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
renderWestFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(3, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
renderNorthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(4, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
renderSouthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(5, metadata), mixedBrightness, adjR, adjG, adjB);
|
||||
// spotless:on
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user