Compare commits

...
39 Commits
Author SHA1 Message Date
Martin Robertz 255a71f3a1 update 2024-09-10 17:27:18 +02:00
Martin Robertz 66019fe027 Merge branch 'master' into bee-lore+name 2024-09-10 17:25:42 +02:00
11eb4b62df Fix broken reflection into GT post-renaming (#80)
* fix reflection

* spotlessApply (#81)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-09-08 22:50:17 +02:00
Nilau1998 5b2a65d2aa [minor] add ability to display bee lore and add Discoverd by tag 2024-09-01 12:17:39 +02:00
Martin Robertz a172cb379f update 2024-08-31 11:27:01 +02:00
Connor-Colenso c979d1fa79 Fix Alveary Mutation Overflow (#76) 2024-08-30 15:09:10 +01:00
Astatine5985 ef5825edcf Bee Mutation Logic Fix (#75) 2024-08-29 21:55:11 +02:00
9570cb2982 Change Radioactive Bee Effect (#72)
* Change up how the radioactive bee works to make it a bit more reasonable.

* Remove debug code

* Fix the range of bees being off by one block. nextInt is [0,n), so we need to do n+1 to get our boundary included.

* Remove unnecessary check, fix alveary block under not using correct y and unprotect other blocks under. Also fix canMineBlock being the wrong way round.

* Fix under block protection for non-alvearies

* spotlessApply (#73)

Co-authored-by: GitHub GTNH Actions <>

* Fix condition

---------

Co-authored-by: GTNH-Colen <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-26 16:49:46 +02:00
Martin Robertz f89a074393 update 2024-06-22 22:09:49 +02:00
chochem 19457080bf dont extend the filter to any meta while optimizing (#74) 2024-06-22 17:30:54 +01:00
Oleg Ivanov d6ec27209b Add ingredients search setting to the worktable (#70) 2024-05-26 16:03:16 +02:00
Martin Robertz a0435886ab update 2024-05-26 12:52:39 +02:00
Ethryan 2ab8613bec Adding a Coin Bag for all those coins. (#71) 2024-05-26 12:48:21 +02:00
Martin Robertz 9d31dedd35 update 2024-05-04 11:43:39 +02:00
slprime 2dd539c3df NEI incorrect tooltip with search 2024-05-04 11:38:09 +02:00
Martin Robertz fd2ac7d172 update 2024-04-16 22:22:28 +02:00
NotAPenguin 466110d461 Fix wrong length check (#68) 2024-04-15 17:47:49 +01:00
Martin Robertz ecf0d7165c update 2024-03-27 09:49:21 +01:00
DrParadox7 dde3514dce Add Butterfly Leaf Spawn Config (#67)
Added `butterfly.entities.disable.leaf.spawns` config to Lepidopterology.cfg.

When set to _True_, it will stop any butterfly from spontaneously spawning from Forestry's leaves [_False_ by default].

Pregnant butterflies remain unaffected for fans of the hobby.
2024-03-26 18:14:34 -07:00
Martin Robertz 0f24a4e043 update 2024-03-04 20:29:49 +01:00
leumasme 3ed2ecfdd0 Fix multifarm not harvesting coffee and tea
Also fixes fermenter recipes for these crops
2024-03-04 16:50:39 +01:00
Martin Robertz be548b06cc update 2024-03-03 09:42:06 +01:00
Jason Mitchell 7db0dc7767 Thread safe (#64)
* update readme and bs

* Thread safe
2024-03-02 21:43:31 +01:00
Jason Mitchell 2e20b14e06 Allocation reduction (#62)
* Allocation reduction
2024-02-18 08:30:15 -08:00
Raven Szewczyk 576afde7b7 [ci skip] upgraded build system 2024-02-04 19:58:32 +00:00
bombcar 7f133a5e2a [bs] fix buildscripts for jenkins (#61) 2024-01-09 12:11:19 -06:00
Raven Szewczyk 0135b39309 [ci skip] upgraded build system 2024-01-08 21:25:44 +00:00
glowredman 2bcd3bb46c Misc cleanup
- add missing `serialVersionUID` fields
- addess vararg warnings
2023-12-29 13:26:43 +01:00
glowredman 646988aae8 Addess some deprecation warnings 2023-12-29 13:26:43 +01:00
glowredman 331c8a8c7b Fix generics 2023-12-29 13:26:43 +01:00
glowredman 68ab1b98bd Add default cases to switch statements 2023-12-29 13:26:43 +01:00
glowredman 9140f84d57 Remove VersionChecker 2023-12-29 13:26:43 +01:00
glowredman bf23ca2317 Update gradle.properties 2023-12-29 13:26:43 +01:00
bombcar 0e4f38b3d1 update buildscript 2023-12-20 19:29:15 +01:00
bombcar eeb29cd7f0 add a name for butterflyGE 2023-12-20 19:29:15 +01:00
DrParadox7 103cd87cbe Mail blacklist implements Set 2023-11-12 18:14:46 +01:00
DrParadox7 1da67c79f3 Rework wildcard imports 2023-11-12 18:14:46 +01:00
DrParadox7 3023b12d83 Update BS 2023-11-12 18:14:46 +01:00
DrParadox7 05c4914c79 Mails are now checked for prohibited items
Added blacklist for Mail envelopes.

It's mainly there to prevent players bypassing the stamp cost by sending out inventories rather than items.
2023-11-12 18:14:46 +01:00
163 changed files with 1524 additions and 2319 deletions

No files matched your search

+2 -12
View File
@@ -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 -1591
View File
File diff suppressed because it is too large. Load diff
+4 -3
View File
@@ -2,9 +2,10 @@
dependencies {
api('curse.maven:cofh-lib-220333:2388748')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.3.81-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.5.16:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.36:api')
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta6:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.6.35-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.0:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.39:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:craftguide-75557:2459320')
}
+165 -22
View File
@@ -1,60 +1,203 @@
# 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.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
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
# 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
# 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
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# 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
# Define a source file of your project with:
# 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<E>, Map<K, V> types.
enableGenericInjection = true
# 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
# 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-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
replaceGradleTokenInFile = Constants.java
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# 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/
# Example value: mymodid_at.cfg
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# 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
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
# 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 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 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 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_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
# 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 to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# 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 =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# 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: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# 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 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 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).
# disableCheckstyle = true
# 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 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
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+17 -10
View File
@@ -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/.
@@ -83,7 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +134,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +205,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_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.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Vendored
+12 -10
View File
@@ -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
+5 -10
View File
@@ -4,10 +4,10 @@ pluginManagement {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
@@ -17,12 +17,7 @@ pluginManagement {
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27'
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
+3
View File
@@ -112,6 +112,9 @@ public class Forestry {
public void postInit(FMLPostInitializationEvent event) {
PluginManager.runPostInit();
// Parse Mail Blacklist
Config.parseMailBlacklist();
// Register world generator
WorldGenerator worldGenerator = new WorldGenerator();
GameRegistry.registerWorldGenerator(worldGenerator, 0);
@@ -34,7 +34,8 @@ public enum FarmDirection {
return SOUTH;
case WEST:
return WEST;
default:
return null;
}
return null;
}
}
@@ -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;
}
@@ -12,12 +12,13 @@ import forestry.api.core.Tabs;
import forestry.apiculture.items.ItemBlockCandle;
import forestry.core.blocks.BlockBase;
import forestry.core.blocks.BlockRegistry;
import forestry.core.blocks.IMachineProperties;
import forestry.core.items.ItemBlockForestry;
public class BlockRegistryApiculture extends BlockRegistry {
public final BlockApiculture apiculture;
public final BlockBase apicultureChest;
public final BlockBase<? extends IMachineProperties> apicultureChest;
public final BlockBeehives beehives;
public final BlockCandle candle;
public final BlockStump stump;
@@ -26,7 +27,7 @@ public class BlockRegistryApiculture extends BlockRegistry {
public BlockRegistryApiculture() {
apiculture = registerBlock(new BlockApiculture(), ItemBlockForestry.class, "apiculture");
apicultureChest = registerBlock(new BlockBase(true), ItemBlockForestry.class, "apicultureChest");
apicultureChest = registerBlock(new BlockBase<>(true), ItemBlockForestry.class, "apicultureChest");
apicultureChest.setCreativeTab(Tabs.tabApiculture);
apicultureChest.setHarvestLevel("axe", 0);
@@ -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;
@@ -26,7 +29,20 @@ import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.*;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -49,6 +65,7 @@ import forestry.core.errors.EnumErrorCode;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.GenericRatings;
import forestry.core.genetics.IndividualLiving;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.Log;
import forestry.core.utils.StringUtil;
@@ -440,6 +457,21 @@ public class Bee extends IndividualLiving implements IBee {
if (genome.getTolerantFlyer()) {
list.add(EnumChatFormatting.WHITE + StringUtil.localize("gui.flyer.tooltip"));
}
// Add lore and discovered by
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 0) {
String speciesLore = descTokens[0];
if (!speciesLore.isEmpty() && Proxies.common.isCtrlDown()) {
list.addAll(StringUtil.multilineStrings(speciesLore, 50));
}
}
if (descTokens.length > 2) {
String discoveredBy = descTokens[2];
if (!discoveredBy.isEmpty()) {
list.add("Discovered by " + discoveredBy);
}
}
}
@Override
@@ -686,9 +718,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) {
@@ -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;
}
@@ -21,7 +21,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 +36,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 +61,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 +70,69 @@ 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.
if (!world.canMineBlock(
housing.getWorld().func_152378_a(housing.getOwner().getId()),
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;
}
}
@@ -13,7 +13,13 @@ import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.*;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleTolerance;
@@ -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;
@@ -39,7 +40,7 @@ import forestry.core.utils.ItemStackUtil;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
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();
@@ -99,7 +99,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
}
@SuppressWarnings("rawtypes")
@SuppressWarnings({ "rawtypes", "unchecked" })
public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List,
Random random, int par3, int par4, int par5, int par6, int par7) {
StructureBoundingBox bbox = StructureBoundingBox
@@ -28,7 +28,6 @@ import forestry.plugins.PluginApiculture;
public abstract class HiveDecorator {
@SuppressWarnings("rawtypes")
private static final EventType EVENT_TYPE = EnumHelper
.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0], new Object[0]);
@@ -168,6 +168,7 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
@SuppressWarnings("deprecation")
ItemStack itemStack = super.getPickBlock(target, world, x, y, z);
TileLeaves leaves = getLeafTile(world, x, y, z);
NBTTagCompound leavesNBT = new NBTTagCompound();
@@ -61,6 +61,7 @@ public class BlockFruitPod extends BlockCocoa {
tile.onBlockTick();
}
@SuppressWarnings("deprecation")
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
if (!world.isRemote) {
@@ -1059,6 +1059,8 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
case WEST:
vanillaWoodMeta |= 1 << 2;
break;
default:
break;
}
world.setBlock(x, y, z, vanillaWoodBlock, vanillaWoodMeta, Constants.FLAG_BLOCK_SYNCH);
@@ -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();
@@ -35,6 +35,7 @@ public abstract class BlockForestry extends BlockContainer {
setCreativeTab(CreativeTabForestry.tabForestry);
}
@SuppressWarnings("deprecation")
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
@@ -16,7 +16,6 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
@@ -50,29 +49,22 @@ public abstract class BlockStructure extends BlockForestry {
}
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof MultiblockTileEntityForestry)) {
if (!(tile instanceof MultiblockTileEntityForestry<?>part)) {
return false;
}
MultiblockTileEntityForestry part = (MultiblockTileEntityForestry) tile;
IMultiblockController controller = part.getMultiblockLogic().getController();
// If the player's hands are empty and they right-click on a multiblock, they get a
// multiblock-debugging message if the machine is not assembled.
if (player.getCurrentEquippedItem() == null && !controller.isAssembled()) {
if (controller != null) {
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = world.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
player.addChatMessage(new ChatComponentText(validationError));
previousMessageTick = tick;
}
return true;
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = world.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
player.addChatMessage(new ChatComponentText(validationError));
previousMessageTick = tick;
}
} else {
player.addChatMessage(
new ChatComponentText(StatCollector.translateToLocal("for.multiblock.error.notConnected")));
return true;
}
}
@@ -94,13 +86,12 @@ public abstract class BlockStructure extends BlockForestry {
return;
}
if (entityLiving instanceof EntityPlayer) {
if (entityLiving instanceof EntityPlayer player) {
TileEntity tile = world.getTileEntity(i, j, k);
if (tile instanceof MultiblockTileEntityForestry) {
EntityPlayer player = (EntityPlayer) entityLiving;
if (tile instanceof MultiblockTileEntityForestry<?>tileForestry) {
GameProfile gameProfile = player.getGameProfile();
((MultiblockTileEntityForestry) tile).setOwner(gameProfile);
tileForestry.setOwner(gameProfile);
}
}
}
@@ -2,5 +2,5 @@ package forestry.core.blocks;
public interface IItemTyped {
Enum getTypeFromMeta(int meta);
Enum<?> getTypeFromMeta(int meta);
}
@@ -109,6 +109,6 @@ public class CircuitRegistry implements ICircuitRegistry {
return null;
}
return new CircuitBoard(nbttagcompound);
return new CircuitBoard<>(nbttagcompound);
}
}
@@ -79,7 +79,6 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
@@ -75,7 +75,7 @@ public class ItemCircuitBoard extends ItemForestryMultiPass {
public static ItemStack createCircuitboard(EnumCircuitBoardType type, ICircuitLayout layout, ICircuit[] circuits) {
ItemStack chipset = PluginCore.items.circuitboards.get(type);
saveChipset(chipset, new CircuitBoard(type, layout, circuits));
saveChipset(chipset, new CircuitBoard<>(type, layout, circuits));
return chipset;
}
@@ -164,7 +164,6 @@ public class CommandHelpers {
return false;
}
@SuppressWarnings("unchecked")
public static List<String> getListOfStringsMatchingLastWord(String[] strings, String... lastWords) {
return CommandBase.getListOfStringsMatchingLastWord(strings, lastWords);
}
@@ -26,24 +26,11 @@ public class CommandVersion extends SubCommand {
@Override
public void processSubCommand(ICommandSender sender, String[] args) {
ChatStyle style = new ChatStyle();
if (Version.isOutdated()) {
style.setColor(EnumChatFormatting.RED);
} else {
style.setColor(EnumChatFormatting.GREEN);
}
CommandHelpers.sendLocalizedChatMessage(
sender,
style,
new ChatStyle().setColor(EnumChatFormatting.GREEN),
"for.chat.version",
Version.getVersion(),
Proxies.common.getMinecraftVersion(),
Version.getRecommendedVersion());
if (Version.isOutdated()) {
for (String updateLine : Version.getChangelog()) {
CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + updateLine);
}
}
Proxies.common.getMinecraftVersion());
}
}
@@ -74,7 +74,7 @@ public class RootCommand extends CommandBase implements IForestryCommand {
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
public List<String> addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
return CommandHelpers.addStandardTabCompletionOptions(this, sender, incomplete);
}
@@ -18,11 +18,13 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import net.minecraft.item.Item;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.Property;
import com.google.common.collect.LinkedListMultimap;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.Forestry;
import forestry.core.fluids.Fluids;
import forestry.core.utils.Log;
@@ -97,6 +99,37 @@ public class Config {
public static GuiMailboxInfo.XPosition mailAlertXPosition = GuiMailboxInfo.XPosition.LEFT;
public static GuiMailboxInfo.YPosition mailAlertYPosition = GuiMailboxInfo.YPosition.TOP;
public static Set<Item> mailBlacklist = new HashSet<Item>();
public static String[] mailBlacklistString;
public static final String[] mailBlacklistDefault = new String[] { "arsmagica2:essenceBag", "arsmagica2:runeBag",
"betterstorage:backpack", "betterstorage:cardboardBox", "betterstorage:thaumcraftBackpack",
"Botania:baubleBox", "Botania:flowerBag", "cardboardboxes:cbCardboardBox", "dendrology:fullDrawers1",
"dendrology:fullDrawers2", "dendrology:fullDrawers4", "dendrology:halfDrawers2", "dendrology:halfDrawers4",
"DQMIIINext:ItemMahounoTutu11", "DQMIIINext:ItemOokinaFukuro", "DQMIIINext:ItemOokinaFukuroB",
"DQMIIINext:ItemOokinaFukuroG", "DQMIIINext:ItemOokinaFukuroR", "DQMIIINext:ItemOokinaFukuroY",
"ExtraUtilities:golden_bag", "HardcoreEnderExpansion:charm_pouch", "ImmersiveEngineering:toolbox",
"ironbackpacks:basicBackpack", "ironbackpacks:diamondBackpack", "ironbackpacks:goldBackpack",
"ironbackpacks:ironBackpack", "JABBA:mover", "JABBA:moverDiamond", "MagicBees:backpack.thaumaturgeT1",
"MagicBees:backpack.thaumaturgeT2", "Mekanism:CardboardBox", "MineFactoryReloaded:plastic.bag",
"OpenBlocks:devnull", "ProjectE:item.pe_alchemical_bag",
"ProjRed|Exploration:projectred.exploration.backpack", "sgs_treasure:dread_pirate_chest",
"sgs_treasure:iron_chest", "sgs_treasure:locked_wooden_chest", "sgs_treasure:obsidian_chest",
"sgs_treasure:pirate_chest", "sgs_treasure:wither_chest", "sgs_treasure:wooden_chest",
"StorageDrawers:compDrawers", "StorageDrawers:fullCustom1", "StorageDrawers:fullCustom2",
"StorageDrawers:fullCustom4", "StorageDrawers:fullDrawers1", "StorageDrawers:fullDrawers2",
"StorageDrawers:fullDrawers4", "StorageDrawers:halfCustom2", "StorageDrawers:halfCustom4",
"StorageDrawers:halfDrawers2", "StorageDrawers:halfDrawers4", "StorageDrawersBop:fullDrawers1",
"StorageDrawersBop:fullDrawers1", "StorageDrawersBop:fullDrawers2", "StorageDrawersBop:fullDrawers2",
"StorageDrawersBop:fullDrawers4", "StorageDrawersBop:fullDrawers4", "StorageDrawersBop:halfDrawers2",
"StorageDrawersBop:halfDrawers2", "StorageDrawersBop:halfDrawers4", "StorageDrawersBop:halfDrawers4",
"StorageDrawersForestry:fullDrawers1A", "StorageDrawersForestry:fullDrawers2A",
"StorageDrawersForestry:fullDrawers4A", "StorageDrawersForestry:halfDrawers2A",
"StorageDrawersForestry:halfDrawers4A", "StorageDrawersNatura:fullDrawers1",
"StorageDrawersNatura:fullDrawers2", "StorageDrawersNatura:fullDrawers4",
"StorageDrawersNatura:halfDrawers2", "StorageDrawersNatura:halfDrawers4", "Thaumcraft:FocusPouch",
"ThaumicTinkerer:ichorPouch", "thebetweenlands:lurkerSkinPouch", "ThermalExpansion:Strongbox",
"ThermalExpansion:satchel", "warpbook:warpbook", "witchery:brewbag", "WitchingGadgets:item.WG_Bag" };
// Gui tabs (Ledger)
public static int guiTabSpeed = 8;
@@ -279,6 +312,11 @@ public class Config {
"yPosition",
mailAlertYPosition,
GuiMailboxInfo.YPosition.values());
mailBlacklistString = configCommon.getStringList(
"mailBlacklist",
"restrictions",
mailBlacklistDefault,
"Items that cannot be shipped through a letter");
guiTabSpeed = configCommon.getIntLocalized("tweaks.gui.tabs", "speed", guiTabSpeed, 1, 50);
enableHints = configCommon.getBooleanLocalized("tweaks.gui.tabs", "hints", enableHints);
@@ -386,4 +424,16 @@ public class Config {
return list.split("[;]+");
}
}
public static void parseMailBlacklist() {
for (String itemName : mailBlacklistString) {
String[] nameAndID;
if (itemName.contains(":") && (nameAndID = itemName.split(":")).length == 2) {
Item item = GameRegistry.findItem(nameAndID[0], nameAndID[1]);
if (item != null) {
mailBlacklist.add(item);
}
}
}
}
}
@@ -8,6 +8,7 @@
******************************************************************************/
package forestry.core.config;
import forestry.Tags;
import forestry.api.core.IForestryConstants;
public class Constants implements IForestryConstants {
@@ -15,7 +16,7 @@ public class Constants implements IForestryConstants {
// System
public static final String MOD = "Forestry";
public static final String ID = "forestry";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String VERSION = Tags.VERSION;
public static final String URL = "http://forestry.sengir.net/";
public static final int FLAG_BLOCK_UPDATE = 1;
@@ -25,6 +25,7 @@ public class ForestryGuiConfig extends GuiConfig {
super(parent, getConfigCategories(), Constants.MOD, true, true, Constants.MOD);
}
@SuppressWarnings("rawtypes")
private static List<IConfigElement> getConfigCategories() {
List<IConfigElement> configElements = new ArrayList<>();
@@ -32,13 +33,13 @@ public class ForestryGuiConfig extends GuiConfig {
.asList("crafting", "difficulty", "genetics", "performance", "structures", "tweaks", "world");
for (String categoryName : commonCategoryNames) {
ConfigCategory category = Config.configCommon.getCategory(categoryName);
configElements.add(new ConfigElement(category));
configElements.add(new ConfigElement<>(category));
}
List<String> fluidCategoryNames = Arrays.asList("enableFluid", "enableFluidBlock");
for (String categoryName : fluidCategoryNames) {
ConfigCategory category = Config.configFluid.getCategory(categoryName);
configElements.add(new ConfigElement(category));
configElements.add(new ConfigElement<>(category));
}
return configElements;
+20 -146
View File
@@ -8,21 +8,7 @@
******************************************************************************/
package forestry.core.config;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import forestry.Forestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Log;
import forestry.Tags;
/**
* With permission from pahimar.
@@ -31,163 +17,51 @@ import forestry.core.utils.Log;
*/
public class Version {
@Deprecated
public enum EnumUpdateState {
CURRENT,
OUTDATED,
CONNECTION_ERROR
}
public static final String VERSION = "@VERSION@";
public static final String BUILD_NUMBER = "@BUILD_NUMBER@";
public static final String VERSION = Tags.VERSION;
@Deprecated
public static final String BUILD_NUMBER = "";
@Deprecated
public static final String[] FAILED_CHANGELOG = new String[] {
String.format("Unable to retrieve changelog for %s", Constants.MOD) };
private static final String REMOTE_VERSION_FILE = "http://bit.ly/forestryver";
private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/forestry/changelog/";
@Deprecated
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
private static String recommendedVersion;
private static String[] cachedChangelog = FAILED_CHANGELOG;
public static String getVersion() {
return VERSION + " (" + BUILD_NUMBER + ")";
return VERSION;
}
@Deprecated
public static boolean isOutdated() {
return currentVersion == EnumUpdateState.OUTDATED;
return false;
}
@Deprecated
public static boolean needsUpdateNoticeAndMarkAsSeen() {
if (!isOutdated()) {
return false;
}
File versionFile = new File(Forestry.instance.getConfigFolder(), Config.CATEGORY_COMMON + ".cfg");
Configuration config = new Configuration(versionFile);
Property property = config.get("version", "seen", VERSION);
property.comment = "indicates the last version the user has been informed about and will suppress further notices on it.";
String seenVersion = property.getString();
if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) {
return false;
}
property.set(recommendedVersion);
config.save();
return true;
return false;
}
@Deprecated
public static String getRecommendedVersion() {
return recommendedVersion;
return VERSION;
}
private static class VersionChecker extends Thread {
@Override
public void run() {
try {
String location = REMOTE_VERSION_FILE;
HttpURLConnection conn = null;
while (location != null && !location.isEmpty()) {
URL url = new URL(location);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)");
conn.connect();
location = conn.getHeaderField("Location");
}
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String mcVersion = Proxies.common.getMinecraftVersion();
while ((line = reader.readLine()) != null) {
if (line.startsWith(mcVersion) && line.contains(Constants.MOD)) {
String[] tokens = line.split(":");
recommendedVersion = tokens[2];
}
}
if (recommendedVersion == null) {
return;
}
int result = FMLCommonHandler.instance().findContainerFor(Forestry.instance).getProcessedVersion()
.compareTo(new DefaultArtifactVersion(recommendedVersion));
if (result >= 0) {
Log.finer(
"Using the latest version [" + VERSION
+ " (build:"
+ BUILD_NUMBER
+ ")] for Minecraft "
+ mcVersion);
currentVersion = EnumUpdateState.CURRENT;
return;
}
cachedChangelog = grabChangelog(recommendedVersion);
Log.warning(
"Using outdated version [" + VERSION
+ " (build:"
+ BUILD_NUMBER
+ ")] for Minecraft "
+ mcVersion
+ ". Consider updating.");
currentVersion = EnumUpdateState.OUTDATED;
} catch (Exception e) {
// e.printStackTrace();
Log.warning("Unable to read from remote version authority.");
currentVersion = EnumUpdateState.CONNECTION_ERROR;
}
}
}
public static void versionCheck() {
new VersionChecker().start();
}
@Deprecated
public static void versionCheck() {}
@Deprecated
public static String[] getChangelog() {
return cachedChangelog;
return FAILED_CHANGELOG;
}
@Deprecated
public static String[] grabChangelog(String version) {
try {
String location = REMOTE_CHANGELOG_ROOT + version;
HttpURLConnection conn;
do {
URL url = new URL(location);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)");
conn.connect();
location = conn.getHeaderField("Location");
} while (location != null && !location.isEmpty());
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
ArrayList<String> changelog = new ArrayList<>();
while ((line = reader.readLine()) != null) {
if (line.startsWith("#")) {
continue;
}
if (line.isEmpty()) {
continue;
}
changelog.add(line);
}
return changelog.toArray(new String[changelog.size()]);
} catch (Exception ex) {
// ex.printStackTrace();
Log.warning("Unable to read changelog from remote site.");
}
return new String[] { String.format("Unable to retrieve changelog for %s %s", Constants.MOD, version) };
return FAILED_CHANGELOG;
}
}
@@ -10,7 +10,6 @@ package forestry.core.fluids;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
@@ -31,7 +30,7 @@ public class FakeTankManager implements ITankManager {
public void containerAdded(Container container, ICrafting player) {}
@Override
public void updateGuiData(Container container, List<EntityPlayerMP> crafters) {}
public void updateGuiData(Container container, List<ICrafting> crafters) {}
@Override
public void containerRemoved(Container container) {}
@@ -10,7 +10,6 @@ package forestry.core.fluids;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraftforge.fluids.FluidStack;
@@ -21,7 +20,7 @@ public interface ITankManager extends IFluidHandler {
void containerAdded(Container container, ICrafting player);
void updateGuiData(Container container, List<EntityPlayerMP> crafters);
void updateGuiData(Container container, List<ICrafting> crafters);
void containerRemoved(Container container);
@@ -17,6 +17,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -134,7 +135,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
return;
}
List<EntityPlayerMP> crafters = Collections.singletonList((EntityPlayerMP) player);
List<ICrafting> crafters = Collections.singletonList(player);
for (StandardTank tank : tanks) {
sendTankUpdate(container, tank, crafters);
@@ -149,13 +150,13 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
@Override
public void updateGuiData(Container container, List<EntityPlayerMP> crafters) {
public void updateGuiData(Container container, List<ICrafting> crafters) {
for (StandardTank tank : tanks) {
updateGuiData(container, crafters, tank.getTankIndex());
}
}
private void updateGuiData(Container container, List<EntityPlayerMP> crafters, int tankIndex) {
private void updateGuiData(Container container, List<ICrafting> crafters, int tankIndex) {
StandardTank tank = tanks.get(tankIndex);
if (tank == null) {
return;
@@ -170,12 +171,12 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
sendTankUpdate(container, tank, crafters);
}
private void sendTankUpdate(Container container, StandardTank tank, Iterable<EntityPlayerMP> crafters) {
private void sendTankUpdate(Container container, StandardTank tank, Iterable<ICrafting> crafters) {
int tankIndex = tank.getTankIndex();
FluidStack fluid = tank.getFluid();
IForestryPacketClient packet = new PacketTankLevelUpdate(tile, tankIndex, fluid);
for (EntityPlayerMP player : crafters) {
Proxies.net.sendToPlayer(packet, player);
for (ICrafting player : crafters) {
Proxies.net.sendToPlayer(packet, (EntityPlayer) player);
}
if (fluid == null) {
@@ -133,8 +133,9 @@ public class StandardTank extends FluidTank implements IStreamable {
case DEFAULT:
case INPUT:
return true;
default:
return false;
}
return false;
}
public boolean canBeDrainedExternally() {
@@ -142,8 +143,9 @@ public class StandardTank extends FluidTank implements IStreamable {
case DEFAULT:
case OUTPUT:
return true;
default:
return false;
}
return false;
}
public boolean canFill(Fluid fluid, int amount) {
@@ -33,7 +33,7 @@ public class AlleleHelper implements IAlleleHelper {
private static final String modId = Constants.ID;
public static AlleleHelper instance;
private final Map<Class, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>();
private final Map<Class<?>, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>();
public void init() {
if (PluginManager.Module.APICULTURE.isEnabled()) {
@@ -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;
}
@@ -38,7 +38,6 @@ public abstract class ContainerLiquidTanks<T extends TileEntity & ILiquidTankTil
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
tile.getTankManager().updateGuiData(this, crafters);
@@ -43,7 +43,6 @@ public abstract class ContainerLiquidTanksSocketed<T extends TileEntity & ILiqui
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
tile.getTankManager().updateGuiData(this, crafters);
@@ -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) {
@@ -302,7 +302,7 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
@Optional.Method(modid = "NotEnoughItems")
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (gui instanceof GuiForestry) {
return ((GuiForestry) gui).ledgerManager.ledgerOverlaps(x, y, w, h);
return ((GuiForestry<?, ?>) gui).ledgerManager.ledgerOverlaps(x, y, w, h);
} else {
return false;
}
@@ -94,7 +94,6 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
@@ -70,7 +70,6 @@ public class GuiTextBox extends GuiTextField {
return text.substring(0, cursorPos) + "_" + text.substring(cursorPos);
}
@SuppressWarnings("unchecked")
private void drawScrolledSplitString(String text, int startX, int startY, int width, int textColour) {
List<String> lines = fontRendererObj.listFormattedStringToWidth(text, width);
maxLines = lines.size();
+3 -3
View File
@@ -25,7 +25,7 @@ import forestry.core.gui.tooltips.ToolTipLine;
public class GuiUtil {
public static void drawItemStack(GuiForestry gui, ItemStack stack, int xPos, int yPos) {
public static void drawItemStack(GuiForestry<?, ?> gui, ItemStack stack, int xPos, int yPos) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
RenderHelper.enableGUIStandardItemLighting();
@@ -50,7 +50,7 @@ public class GuiUtil {
GL11.glPopAttrib();
}
public static void drawToolTips(GuiForestry gui, ToolTip toolTips, int mouseX, int mouseY) {
public static void drawToolTips(GuiForestry<?, ?> gui, ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips == null) {
return;
}
@@ -144,7 +144,7 @@ public class GuiUtil {
itemRender.zLevel = 0.0F;
}
public static void drawToolTips(GuiForestry gui, Collection<?> objects, int mouseX, int mouseY) {
public static void drawToolTips(GuiForestry<?, ?> gui, Collection<?> objects, int mouseX, int mouseY) {
for (Object obj : objects) {
if (!(obj instanceof IToolTipProvider)) {
continue;
@@ -9,6 +9,8 @@
package forestry.core.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import org.lwjgl.opengl.GL11;
@@ -18,7 +20,7 @@ public class TextLayoutHelper {
private static final int LINE_HEIGHT = 12;
private final GuiForestry guiForestry;
private final GuiForestry<? extends Container, ? extends IInventory> guiForestry;
private final int defaultFontColor;
private FontRenderer fontRendererObj;
@@ -27,7 +29,7 @@ public class TextLayoutHelper {
public int column2;
public int line;
public TextLayoutHelper(GuiForestry guiForestry, FontColour fontColour) {
public TextLayoutHelper(GuiForestry<? extends Container, ? extends IInventory> guiForestry, FontColour fontColour) {
this.guiForestry = guiForestry;
this.defaultFontColor = fontColour.get("gui.screen");
}
@@ -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
@@ -227,12 +231,10 @@ public abstract class Ledger {
protected int drawSplitText(String string, int x, int y, int width, int color, boolean shadow) {
int originalY = y;
Minecraft minecraft = Proxies.common.getClientInstance();
List strings = minecraft.fontRenderer.listFormattedStringToWidth(string, width);
for (Object obj : strings) {
if (obj instanceof String) {
minecraft.fontRenderer.drawString((String) obj, x, y, color, shadow);
y += minecraft.fontRenderer.FONT_HEIGHT;
}
List<String> strings = minecraft.fontRenderer.listFormattedStringToWidth(string, width);
for (String obj : strings) {
minecraft.fontRenderer.drawString(obj, x, y, color, shadow);
y += minecraft.fontRenderer.FONT_HEIGHT;
}
return y - originalY;
}
@@ -11,6 +11,9 @@ package forestry.core.gui.ledgers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import org.lwjgl.opengl.GL11;
import forestry.api.core.IErrorSource;
@@ -29,9 +32,9 @@ public class LedgerManager {
private IErrorSource errorSource;
private final int maxWidth;
public final GuiForestry gui;
public final GuiForestry<? extends Container, ? extends IInventory> gui;
public LedgerManager(GuiForestry gui, int maxWidth) {
public LedgerManager(GuiForestry<? extends Container, ? extends IInventory> gui, int maxWidth) {
this.gui = gui;
this.errorSource = FakeErrorSource.instance;
this.maxWidth = maxWidth;
@@ -156,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
@@ -39,7 +39,7 @@ public class ToolTip extends ForwardingList<ToolTipLine> {
return add(new ToolTipLine(line));
}
public boolean add(List lines) {
public boolean add(List<?> lines) {
boolean changed = false;
for (Object line : lines) {
if (line instanceof String) {
@@ -54,7 +54,6 @@ public class SocketWidget extends Widget {
private final ToolTip toolTip = new ToolTip(250) {
@SuppressWarnings("unchecked")
@Override
public void refresh() {
toolTip.clear();
@@ -12,6 +12,8 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import org.lwjgl.opengl.GL11;
@@ -20,11 +22,11 @@ import forestry.core.proxy.Proxies;
public class WidgetManager {
public final GuiForestry gui;
public final GuiForestry<? extends Container, ? extends IInventory> gui;
public final Minecraft minecraft;
protected final List<Widget> widgets = new ArrayList<>();
public WidgetManager(GuiForestry gui) {
public WidgetManager(GuiForestry<? extends Container, ? extends IInventory> gui) {
this.gui = gui;
this.minecraft = Proxies.common.getClientInstance();
}
@@ -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);
}
}
@@ -120,7 +120,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
coord);
}
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.setController(this);
this.onBlockAdded(part);
@@ -138,7 +138,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
TileEntity te = this.worldObj.getTileEntity(referenceCoord.posX, referenceCoord.posY, referenceCoord.posZ);
if (te instanceof IMultiblockComponent) {
IMultiblockComponent tePart = (IMultiblockComponent) te;
MultiblockLogic teLogic = (MultiblockLogic) tePart.getMultiblockLogic();
MultiblockLogic<?> teLogic = (MultiblockLogic<?>) tePart.getMultiblockLogic();
teLogic.forfeitMultiblockSaveDelegate();
}
@@ -219,7 +219,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
*/
private void onDetachBlock(IMultiblockComponent part) {
// Strip out this part
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.setController(null);
this.onBlockRemoved(part);
logic.forfeitMultiblockSaveDelegate();
@@ -361,7 +361,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
}
connectedParts.add(acquiredPart);
MultiblockLogic logic = (MultiblockLogic) acquiredPart.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) acquiredPart.getMultiblockLogic();
logic.setController(this);
this.onBlockAdded(acquiredPart);
}
@@ -383,7 +383,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
.getTileEntity(referenceCoord.posX, referenceCoord.posY, referenceCoord.posZ);
if (te instanceof IMultiblockComponent) {
IMultiblockComponent part = (IMultiblockComponent) te;
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.forfeitMultiblockSaveDelegate();
}
}
@@ -745,7 +745,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
continue;
}
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.setUnvisited();
logic.forfeitMultiblockSaveDelegate();
@@ -769,7 +769,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
MultiblockRegistry.addDeadController(worldObj, this);
return Collections.emptySet();
} else {
MultiblockLogic logic = (MultiblockLogic) referencePart.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) referencePart.getMultiblockLogic();
logic.becomeMultiblockSaveDelegate();
}
@@ -781,7 +781,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
while (!partsToCheck.isEmpty()) {
part = partsToCheck.removeFirst();
MultiblockLogic partLogic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> partLogic = (MultiblockLogic<?>) part.getMultiblockLogic();
partLogic.setVisited();
List<IMultiblockComponent> nearbyParts = MultiblockUtil.getNeighboringParts(worldObj, part); // Chunk-safe
@@ -790,7 +790,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
// client
for (IMultiblockComponent nearbyPart : nearbyParts) {
// Ignore different machines
MultiblockLogic nearbyPartLogic = (MultiblockLogic) nearbyPart.getMultiblockLogic();
MultiblockLogic<?> nearbyPartLogic = (MultiblockLogic<?>) nearbyPart.getMultiblockLogic();
if (nearbyPartLogic.getController() != this) {
continue;
}
@@ -805,7 +805,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
// Finally, remove all parts that remain disconnected.
Set<IMultiblockComponent> removedParts = new HashSet<>();
for (IMultiblockComponent orphanCandidate : connectedParts) {
MultiblockLogic logic = (MultiblockLogic) orphanCandidate.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) orphanCandidate.getMultiblockLogic();
if (!logic.isVisited()) {
deadParts.add(orphanCandidate);
onDetachBlock(orphanCandidate);
@@ -877,7 +877,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
}
if (theChosenOne != null) {
MultiblockLogic logic = (MultiblockLogic) theChosenOne.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) theChosenOne.getMultiblockLogic();
logic.becomeMultiblockSaveDelegate();
}
}
@@ -8,6 +8,8 @@ package forestry.core.multiblock;
*/
public class MultiblockValidationException extends Exception {
private static final long serialVersionUID = -3255564315819077747L;
public MultiblockValidationException(String reason) {
super(reason);
}
@@ -135,7 +135,7 @@ public class MultiblockWorldRegistry {
if (compatibleControllers.size() == 0) {
// FOREVER ALONE! Create and register a new controller.
// THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE CREATED.
MultiblockLogic logic = (MultiblockLogic) orphan.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) orphan.getMultiblockLogic();
IMultiblockControllerInternal newController = logic.createNewController(worldObj);
newController.attachBlock(orphan);
this.controllers.add(newController);
@@ -263,7 +263,7 @@ public class MultiblockWorldRegistry {
// list, and will be checked next tick to see if their chunk is still loaded.
for (IMultiblockComponent part : detachedParts) {
// Ensure parts know they're detached
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.assertDetached(part);
}
@@ -276,7 +276,7 @@ public class MultiblockWorldRegistry {
Set<IMultiblockControllerInternal> controllers = new HashSet<>();
IMultiblockControllerInternal bestController = null;
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
Class<?> controllerClass = logic.getControllerClass();
// Look for a compatible controller in our neighboring parts.
List<IMultiblockComponent> partsToCheck = MultiblockUtil.getNeighboringParts(worldObj, part);
@@ -367,7 +367,7 @@ public class MultiblockWorldRegistry {
}
}
MultiblockLogic logic = (MultiblockLogic) part.getMultiblockLogic();
MultiblockLogic<?> logic = (MultiblockLogic<?>) part.getMultiblockLogic();
logic.assertDetached(part);
}
@@ -75,7 +75,7 @@ public class DataInputStreamForestry extends DataInputStream {
public <T extends IStreamable> T readStreamable(Class<T> streamableClass) throws IOException {
if (readBoolean()) {
try {
T streamable = streamableClass.newInstance();
T streamable = streamableClass.getConstructor().newInstance();
streamable.readData(this);
return streamable;
} catch (ReflectiveOperationException e) {
@@ -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());
@@ -46,7 +46,7 @@ public class PacketGuiEnergy extends ForestryPacket implements IForestryPacketCl
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
if (player.openContainer instanceof ContainerTile && player.openContainer.windowId == windowId) {
((ContainerTile) player.openContainer).onGuiEnergy(value);
((ContainerTile<?>) player.openContainer).onGuiEnergy(value);
}
}
@@ -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);
@@ -34,7 +34,7 @@ import forestry.factory.inventory.InventoryCraftingForestry;
public abstract class RecipeUtil {
static List<Object> cachedRecipes = new ArrayList<Object>();
static List<IRecipe> cachedRecipes = new ArrayList<>();
public static void addFermenterRecipes(ItemStack resource, int fermentationValue, Fluids output) {
if (RecipeManagers.fermenterManager == null) {
@@ -183,15 +183,14 @@ public abstract class RecipeUtil {
}
List<ItemStack> matchingRecipes = new ArrayList<>();
List<Integer> matchingIndex = new ArrayList();
List<Object> matchingRecipeMap = new ArrayList();
List<Integer> matchingIndex = new ArrayList<>();
List<IRecipe> matchingRecipeMap = new ArrayList<>();
int index = 0;
if (Config.cacheWorktableRecipes) {
// Check across the whole cached recipe map
// Add each recipe to the matchingRecipes list
for (Object recipe : cachedRecipes) {
IRecipe irecipe = (IRecipe) recipe;
for (IRecipe irecipe : cachedRecipes) {
if (irecipe.matches(inventory, world)) {
ItemStack result = irecipe.getCraftingResult(inventory);
@@ -206,8 +205,7 @@ public abstract class RecipeUtil {
}
}
// Only do this if there were no cached recipes hit
for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
IRecipe irecipe = (IRecipe) recipe;
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
if (irecipe.matches(inventory, world)) {
ItemStack result = irecipe.getCraftingResult(inventory);
@@ -216,8 +214,8 @@ public abstract class RecipeUtil {
if (Config.promoteWorktableRecipesToFrontOfGlobalRecipemap || Config.cacheWorktableRecipes) {
// Add to the back of the list. That way when we cycle through the list
// moving items to the front, the index locations for the following items doesn't change
matchingRecipeMap.add(recipe);
matchingIndex.add(new Integer(index));
matchingRecipeMap.add(irecipe);
matchingIndex.add(index);
}
}
}
@@ -227,7 +225,7 @@ public abstract class RecipeUtil {
if (Config.promoteWorktableRecipesToFrontOfGlobalRecipemap) {
// Only move the recipes if the last one was beyond 500 in the recipeMap (in GTNH about 57k recipes)
if (matchingIndex.get(matchingIndex.size() - 1) > 500) {
List recipeMap = CraftingManager.getInstance().getRecipeList();
List<IRecipe> recipeMap = CraftingManager.getInstance().getRecipeList();
// System.out.println( "Highest recipe found at " + matchingIndex.get(matchingIndex.size()-1) + ",
// moving " + matchingIndex.size() + " to front" );
// System.out.println( "Size of recipe map " + recipeMap.size() );
@@ -295,12 +293,10 @@ public abstract class RecipeUtil {
addRecipe(new ItemStack(item), obj);
}
@SuppressWarnings("unchecked")
public static void addRecipe(ItemStack itemstack, Object... obj) {
CraftingManager.getInstance().getRecipeList().add(new ShapedRecipeCustom(itemstack, obj));
}
@SuppressWarnings("unchecked")
public static void addPriorityRecipe(ItemStack itemStack, Object... obj) {
CraftingManager.getInstance().getRecipeList().add(0, new ShapedRecipeCustom(itemStack, obj));
}
@@ -309,7 +305,6 @@ public abstract class RecipeUtil {
addShapelessRecipe(new ItemStack(item), obj);
}
@SuppressWarnings("unchecked")
public static void addShapelessRecipe(ItemStack itemstack, Object... obj) {
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(itemstack, obj));
}
@@ -400,7 +395,7 @@ public abstract class RecipeUtil {
} else if (recipeIngredient instanceof ItemStack) {
return ItemStackUtil.isCraftingEquivalent((ItemStack) recipeIngredient, resource);
} else if (recipeIngredient instanceof Iterable) {
for (Object item : (Iterable) recipeIngredient) {
for (Object item : (Iterable<?>) recipeIngredient) {
if (checkIngredientMatch(item, resource)) {
return true;
}
@@ -35,7 +35,7 @@ public class PositionedStackAdv extends PositionedStack {
return new Rectangle(this.relx - 1, this.rely - 1, 18, 18);
}
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip) {
public List<String> handleTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip) {
if (!this.tooltip.isEmpty()) {
for (String tip : this.tooltip) {
currenttip.add(tip);
@@ -114,13 +114,18 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
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);
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
if (recipeIndex >= 0) {
Point offset = guiRecipe.getRecipePosition(recipeIndex);
Point relMouse = new Point(
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
}
}
return currenttip;
}
@@ -130,16 +135,21 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
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);
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
if (recipeIndex >= 0) {
Point offset = guiRecipe.getRecipePosition(recipeIndex);
Point relMouse = new Point(
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
}
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
return currenttip;
}
public List<String> provideTooltip(GuiRecipe guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe,
public List<String> provideTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe,
Point relMouse) {
if (crecipe.getFluidTanks() != null) {
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
@@ -151,7 +161,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
return currenttip;
}
public List<String> provideItemTooltip(GuiRecipe guiRecipe, ItemStack itemStack, List<String> currenttip,
public List<String> provideItemTooltip(GuiRecipe<?> guiRecipe, ItemStack itemStack, List<String> currenttip,
CachedBaseRecipe crecipe, Point relMouse) {
for (PositionedStack stack : crecipe.getIngredients()) {
if (stack instanceof PositionedStackAdv && ((PositionedStackAdv) stack).getRect().contains(relMouse)) {
@@ -171,7 +181,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
}
@Override
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
public boolean keyTyped(GuiRecipe<?> gui, char keyChar, int keyCode, int recipe) {
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) {
if (this.transferFluidTank(gui, recipe, false)) {
return true;
@@ -185,7 +195,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
}
@Override
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
public boolean mouseClicked(GuiRecipe<?> gui, int button, int recipe) {
if (button == 0) {
if (this.transferFluidTank(gui, recipe, false)) {
return true;
@@ -198,7 +208,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
return super.mouseClicked(gui, button, recipe);
}
protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) {
protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean usage) {
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
Point mousepos = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
@@ -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);
@@ -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;
}
}
}
@@ -31,6 +31,7 @@ import forestry.core.config.Constants;
import forestry.core.tiles.TileEngine;
import forestry.core.utils.vect.Vect;
@SuppressWarnings("unchecked")
public abstract class BlockUtil {
private static final int slabWoodId = OreDictionary.getOreID("slabWood");
@@ -240,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();
}
@@ -59,13 +59,11 @@ public abstract class EntityUtil {
Log.finer("Registered entity %s (%s) with id %s.", ident, entityClass.toString(), id);
}
@SuppressWarnings("unchecked")
public static <T extends Entity> List<T> getEntitiesWithinAABB(World world, Class<T> entityClass,
AxisAlignedBB boundingBox) {
return world.getEntitiesWithinAABB(entityClass, boundingBox);
}
@SuppressWarnings("unchecked")
public static <T extends Entity> List<T> selectEntitiesWithinAABB(World world, EntitySelector<T> entitySelector,
AxisAlignedBB boundingBox) {
return world.selectEntitiesWithinAABB(entitySelector.getEntityClass(), boundingBox, entitySelector);
+1 -1
View File
@@ -123,7 +123,7 @@ public abstract class Log {
LogManager.getLogger(Constants.MOD).log(level, new MessageFormatMessage(msg, args), error);
}
public static void logErrorAPI(String mod, Throwable error, Class classFile) {
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
StringBuilder msg = new StringBuilder(mod);
msg.append(" API error, please update your mods. Error: ").append(error);
logThrowable(Level.ERROR, msg.toString(), 2, error);
@@ -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));
}
}
+14 -13
View File
@@ -62,8 +62,8 @@ public abstract class SlotUtil {
return stack;
}
public static ItemStack transferStackInSlot(List inventorySlots, EntityPlayer player, int slotIndex) {
Slot slot = (Slot) inventorySlots.get(slotIndex);
public static ItemStack transferStackInSlot(List<Slot> inventorySlots, EntityPlayer player, int slotIndex) {
Slot slot = inventorySlots.get(slotIndex);
if (slot == null || !slot.getHasStack()) {
return null;
}
@@ -93,7 +93,7 @@ public abstract class SlotUtil {
return originalStack;
}
private static boolean shiftItemStack(List inventorySlots, ItemStack stackInSlot, int slotIndex, int numSlots,
private static boolean shiftItemStack(List<Slot> inventorySlots, ItemStack stackInSlot, int slotIndex, int numSlots,
boolean fromCraftingSlot) {
if (isInPlayerInventory(slotIndex)) {
if (shiftToMachineInventory(inventorySlots, stackInSlot, numSlots)) {
@@ -160,13 +160,14 @@ public abstract class SlotUtil {
slot.putStack(phantomStack);
}
private static boolean shiftItemStackToRange(List inventorySlots, ItemStack stackToShift, int start, int count) {
private static boolean shiftItemStackToRange(List<Slot> inventorySlots, ItemStack stackToShift, int start,
int count) {
boolean changed = shiftItemStackToRangeMerge(inventorySlots, stackToShift, start, count);
changed |= shiftItemStackToRangeOpenSlots(inventorySlots, stackToShift, start, count);
return changed;
}
private static boolean shiftItemStackToRangeMerge(List inventorySlots, ItemStack stackToShift, int start,
private static boolean shiftItemStackToRangeMerge(List<Slot> inventorySlots, ItemStack stackToShift, int start,
int count) {
if (stackToShift == null || !stackToShift.isStackable() || stackToShift.stackSize <= 0) {
return false;
@@ -174,7 +175,7 @@ public abstract class SlotUtil {
boolean changed = false;
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
Slot slot = (Slot) inventorySlots.get(slotIndex);
Slot slot = inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot != null && ItemStackUtil.isIdenticalItem(stackInSlot, stackToShift)) {
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
@@ -195,7 +196,7 @@ public abstract class SlotUtil {
return changed;
}
private static boolean shiftItemStackToRangeOpenSlots(List inventorySlots, ItemStack stackToShift, int start,
private static boolean shiftItemStackToRangeOpenSlots(List<Slot> inventorySlots, ItemStack stackToShift, int start,
int count) {
if (stackToShift == null || stackToShift.stackSize <= 0) {
return false;
@@ -203,7 +204,7 @@ public abstract class SlotUtil {
boolean changed = false;
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
Slot slot = (Slot) inventorySlots.get(slotIndex);
Slot slot = inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot == null) {
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
@@ -229,7 +230,7 @@ public abstract class SlotUtil {
return SlotUtil.isSlotInRange(slotIndex, playerInventorySize - playerHotbarSize, playerInventorySize);
}
private static boolean shiftToPlayerInventory(List inventorySlots, ItemStack stackInSlot) {
private static boolean shiftToPlayerInventory(List<Slot> inventorySlots, ItemStack stackInSlot) {
int playerHotbarStart = playerInventorySize - playerHotbarSize;
// try to merge with existing stacks, hotbar first
@@ -242,17 +243,17 @@ public abstract class SlotUtil {
return shifted;
}
private static boolean shiftToPlayerInventoryNoHotbar(List inventorySlots, ItemStack stackInSlot) {
private static boolean shiftToPlayerInventoryNoHotbar(List<Slot> inventorySlots, ItemStack stackInSlot) {
int playerHotbarStart = playerInventorySize - playerHotbarSize;
return shiftItemStackToRange(inventorySlots, stackInSlot, 0, playerHotbarStart);
}
private static boolean shiftToHotbar(List inventorySlots, ItemStack stackInSlot) {
private static boolean shiftToHotbar(List<Slot> inventorySlots, ItemStack stackInSlot) {
int playerHotbarStart = playerInventorySize - playerHotbarSize;
return shiftItemStackToRange(inventorySlots, stackInSlot, playerHotbarStart, playerHotbarSize);
}
private static boolean shiftToMachineInventory(List inventorySlots, ItemStack stackToShift, int numSlots) {
private static boolean shiftToMachineInventory(List<Slot> inventorySlots, ItemStack stackToShift, int numSlots) {
boolean success = false;
if (stackToShift.isStackable()) {
success = shiftToMachineInventory(inventorySlots, stackToShift, numSlots, true);
@@ -264,7 +265,7 @@ public abstract class SlotUtil {
}
// if mergeOnly = true, don't shift into empty slots.
private static boolean shiftToMachineInventory(List inventorySlots, ItemStack stackToShift, int numSlots,
private static boolean shiftToMachineInventory(List<Slot> inventorySlots, ItemStack stackToShift, int numSlots,
boolean mergeOnly) {
for (int machineIndex = playerInventorySize; machineIndex < numSlots; machineIndex++) {
// System.out.println("SlotUtil::shiftToMachineinventory");
@@ -8,7 +8,9 @@
******************************************************************************/
package forestry.core.utils;
import java.util.ArrayList;
import java.util.IllegalFormatException;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -116,4 +118,26 @@ public class StringUtil {
return lineCount * fontRenderer.FONT_HEIGHT;
}
public static List<String> multilineStrings(String input, int n) {
List<String> result = new ArrayList<>();
int start = 0;
while (start < input.length()) {
// Find the end index by starting with n characters ahead
int end = Math.min(start + n, input.length());
// If end is not at the end of the string, backtrack to the last space
if (end < input.length() && !Character.isWhitespace(input.charAt(end))) {
int lastSpace = input.lastIndexOf(' ', end);
if (lastSpace > start) {
end = lastSpace;
}
}
result.add(input.substring(start, end).trim());
start = end;
}
return result;
}
}
@@ -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);
}
}
@@ -51,8 +51,9 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
case EXTRACT:
case BOTH:
return true;
default:
return false;
}
return false;
}
private boolean canReceive() {
@@ -60,8 +61,9 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
case RECEIVE:
case BOTH:
return true;
default:
return false;
}
return false;
}
/* NBT */
@@ -67,8 +67,7 @@ public class BlockEngine extends BlockBase<BlockEngineType> {
}
@Override
@SuppressWarnings("unchecked")
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List list,
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List<AxisAlignedBB> list,
Entity colliding) {
TileEngine tile = TileUtil.getTile(world, x, y, z, TileEngine.class);
if (tile == null) {
@@ -32,7 +32,6 @@ public class ContainerEngineBiogas extends ContainerLiquidTanks<TileEngineBiogas
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
@@ -32,7 +32,6 @@ public class ContainerGenerator extends ContainerLiquidTanks<TileGenerator> {
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
@@ -69,7 +69,6 @@ public class ContainerFabricator extends ContainerLiquidTanks<TileFabricator> im
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
@@ -37,7 +37,6 @@ public class ContainerFermenter extends ContainerLiquidTanks<TileFermenter> {
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
@@ -58,7 +58,6 @@ public class ContainerMoistener extends ContainerLiquidTanks<TileMoistener> impl
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
@@ -34,7 +34,6 @@ public class ContainerRaintank extends ContainerLiquidTanks<TileRaintank> {
}
@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
super.detectAndSendChanges();
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff. Show more