Compare commits

...
88 Commits
Author SHA1 Message Date
Martin Robertz 81b1de6925 update 2025-10-25 15:59:10 +02:00
DarkShadow44andMartin Robertz 278d091b08 Drop contents of Alveary when it's broken (#102)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-25 15:58:35 +02:00
querns 1552ad1b68 Adds configurable display of backpack fullness (#101) 2025-10-25 15:45:46 +02:00
Alexdoru bf94b22345 add public getters to use in gt5u (#100) 2025-08-08 17:15:06 +00:00
Alexdoru c89b61682a use EnumChatFormatting and not Realms enum to avoid crash (#99) 2025-07-21 11:00:21 +02:00
Dream Master 43fc136fe3 update 2025-07-18 10:15:39 +07:00
boubou19 ea52fa0d55 Speed up forge event registration (#98) 2025-07-17 18:49:32 +00:00
Martin Robertz 725d556718 update 2025-07-10 11:11:16 +02:00
Yoshy d88c007fbb Add missing = in Localisation (#97) 2025-07-09 22:28:25 +00:00
Martin Robertz 485333c6aa update 2025-06-20 23:40:15 +02:00
slprime 240802082e Change NEIHandler Tooltip Position (#96) 2025-06-16 07:46:05 +02:00
Martin Robertz 6f182e932d update 2025-06-03 20:22:19 +02:00
d08b42f18c Protect some calls that lead to loadChunk with blockExists (#91)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: boubou19 <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-06-01 21:05:22 +00:00
Martin Robertz 57cc915a1e update 2025-05-25 15:29:38 +02:00
DrParadox7 d7c5940596 Disable flowers that cannot be planted (#94) 2025-05-25 15:28:01 +02:00
Martin Robertz 79a6af701b update 2025-05-17 12:17:12 +02:00
dibbydoda 4c0b503b8b Add thunder substrate for rainmaker (#95) 2025-05-17 11:39:34 +02:00
thedarkcolour 2a6f3771a3 Fix multiblock components to drop inventory contents when broken (#93) 2025-04-20 05:39:48 +00:00
Maya 04a7c96b4d update 2025-04-19 09:19:48 -05:00
dibbydoda 6d0a001b9e Habitat locator mouse hover shows Hellish temperature in the Nether (#92) 2025-04-19 09:19:35 -05:00
Maya e2c2ff8d30 update 2025-03-10 16:18:15 -05:00
Demiu 586f5bf093 Fix alveary climate logic (#90) 2025-03-10 16:16:16 -05:00
Maya 755301d313 update 2025-02-22 22:50:41 -06:00
Discreater 33f3389b84 Add missing localization (#89) 2025-02-22 22:50:30 -06:00
Maya c9167b8316 update 2025-02-14 00:22:07 -06:00
Yannick Marcotte-Gourde 1ed646b147 Don't crash if someone tries to color number values stored in lang files (#88) 2025-02-14 00:21:59 -06:00
Martin Robertz 7a7930d7eb update 2024-12-31 14:25:14 +01:00
glowredman 3dccc7e06d Add Localizations (#87) 2024-12-30 18:18:18 -06:00
Martin Robertz 18e26956ef update 2024-12-18 17:51:39 +01:00
combusterfandMarcel Sondaar 713b0f9d9e fix: Use GT ash instead of letting unification screw everything up. (#86)
Co-authored-by: Marcel Sondaar <[email protected]>
2024-12-18 07:23:38 +01:00
Martin Robertz c6f2e3c7b3 update 2024-11-22 21:37:18 +01:00
chochem c6d8518d82 fix apatite ore crash (#85) 2024-11-21 17:11:44 +00:00
Dream Master 98711e5d34 update 2024-11-18 12:00:06 +01:00
Glease 5caab59507 close item inventory if parent item is gone (#84) 2024-11-18 11:38:20 +01:00
Martin Robertz 41d47d99ca update 2024-11-16 15:40:01 +01:00
Alexander Anishin 3c6d5d04d0 Fix NPE in logic of radioactive effect (#83) 2024-11-16 12:04:33 +01:00
Martin Robertz 137927b3e6 update 2024-09-12 08:20:39 +02:00
Nico SpiskeandMartin Robertz 8aa7e05bbe Add ability to display bee lore and add Discoverd by tag (#79)
* [minor] add ability to display bee lore and add Discoverd by tag

* [minor] better formatting, logic for bees, trees and butterflies.

* [minor] changes according to review

---------

Co-authored-by: Martin Robertz <[email protected]>
2024-09-12 07:34:49 +02:00
chochem 16414da3f2 Remove duplicate items (#82)
* remove some items if dreamcraft is loaded

* sa
2024-09-11 19:27:41 +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
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
miozune bf6bf6846a Update dependency types (#56) 2023-08-12 10:37:19 +02:00
Martin Robertz ba6f1d6249 sa 2023-07-18 20:31:15 +02:00
Martin Robertz 64e861af85 deps 2023-07-18 20:31:06 +02:00
Martin Robertz 27a4d86108 bs 2023-07-18 20:30:42 +02:00
hacatuandJakub afc859c6e9 Fix Additive Production (#55)
* Fixed Secondary Species Primary Production
Calling Math.round on probabilities is a logical error

* gradle spotlessApply

* Fixed computation of BeeModifiers to be consistent with additive modifiers

Needs work in other mods (Binnie and MagicBees)

* Fixed doubled base production modifier, fixed tooltips for frames with negative modifiers

* Fixed floating point bug if productionModifier is negative

* Fixed floating point bug if productionModifier + tier is negative

* Float constant suffix

* Actually fix base production modifier

* Improve tooltip coloring, correct production modifier self capping, add float suffixes

* More tooltip improvments

* Nerf base production (apiaries in shambles)

* Halve forestry frame production boost

Co-authored-by: Jakub <[email protected]>

* Added flowering modifier to tooltips

I believe one of the blood magic frames has a non-default flowering modifier

* Fixed flowering modifier in tooltip and made default values visible

---------

Co-authored-by: Jakub <[email protected]>
2023-07-18 20:28:03 +02:00
初夏同学 6292b4569f Fix a bug when NBTString does not exist. (#54) 2023-07-02 09:48:59 +09:00
Runakai1GitHub GTNH Actionsgithub-actions[bot]
99ebd8efe0 Fix Alveary Simulation of Temperatures (#52)
* Fix Alveary Simulation of Temperatures

* Spottless

* spotlessApply (#53)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-18 14:56:09 +02:00
Dane Strandboge 29df6ceb1b Auto-apply stats tooltips to all IHiveFrame items (#51)
* Auto-apply stats tooltips to all IHiveFrame items

* allow generated tooltip to be overridden

* link event in api, update production tooltip
2023-04-28 18:54:35 +02:00
AlastorsandJason Mitchell 39c822df8a Fixes the incompatability with the newest NEI
Thanks Mitchbama

Co-Authored-By: Jason Mitchell <[email protected]>
2023-04-26 17:49:04 -07:00
Jakub 9e9ae6bcad Support GT_Block_Machines in mutation requirements (#48) 2023-04-07 17:50:43 +02:00
Jakub 661a5598ea New bees formula (#45)
* New formula

* Make production modifier globally additive
2023-03-29 17:26:15 +02:00
Jakub d96669f5f7 Add a way to simulate night (#46)
* Add a way to simulate night

* Add default value to avoid crashes

* Delighted -> Unlighted
2023-03-27 21:01:10 +02:00
Quetz4l ca9ebbc0ed add setting to config-> disable butterflies spawn (#44)
* bs

* add setting to config-> disable butterflies spawn
+ default disable is false

* changed name DISABLE_BUTTERFLY to disableButterfly

* changed Boolean to boolean
(for disableButterfly)
2023-03-20 21:48:43 +01:00
232 changed files with 2441 additions and 2291 deletions

No files matched your search

-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env bash
RUNDIR="run"
CRASH="crash-reports"
SERVERLOG="server.log"
if [[ -d $RUNDIR/$CRASH ]]; then
echo "Crash reports detected:"
cat $RUNDIR/$CRASH/crash*.txt
exit 1
fi
if grep --quiet "Fatal errors were detected" $SERVERLOG; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" $SERVERLOG; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' $SERVERLOG; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+1
View File
@@ -30,3 +30,4 @@ src/main/resources/mixins.*.json
*.bat
*.DS_Store
!gradlew.bat
layout.json
+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 -1259
View File
File diff suppressed because it is too large. Load diff
+6 -7
View File
@@ -1,12 +1,11 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev')
compile('com.github.GTNewHorizons:inventory-tweaks:1.5.14:api')
compile('com.github.GTNewHorizons:BuildCraft:7.1.27:api')
compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compile('curse.maven:cofh-lib-220333:2388748')
api('curse.maven:cofh-lib-220333:2388748')
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta62:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.21-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.45:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:craftguide-75557:2459320')
}
+169 -24
View File
@@ -1,60 +1,205 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Forestry
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = Forestry
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = forestry
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# 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
accessTransformersFile =
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = forestry_at.cfg
# 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!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this 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: UniMixins 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-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+20 -13
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,10 +85,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# 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\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +133,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.
@@ -144,7 +147,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
@@ -152,7 +155,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
@@ -197,11 +200,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# 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 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
-22
View File
@@ -1,26 +1,4 @@
// Add any additional repositiroes for your dependencies here
repositories {
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
name 'ic2'
url 'http://maven.ic2.player.to/'
metadataSources {
mavenPom()
artifact()
}
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
+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.46'
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
+8
View File
@@ -15,6 +15,7 @@ import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.ModAPIManager;
@@ -79,11 +80,15 @@ public class Forestry {
public static PacketHandler packetHandler;
public static boolean isDreamcraftLoaded;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
checkForCoFHLib();
packetHandler = new PacketHandler();
isDreamcraftLoaded = Loader.isModLoaded("dreamcraft");
// Register event handler
EventHandlerCore eventHandlerCore = new EventHandlerCore();
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
@@ -112,6 +117,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);
@@ -24,7 +24,7 @@ public class DefaultBeeModifier implements IBeeModifier {
}
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
return 0.0f;
}
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
@@ -43,6 +43,10 @@ public class DefaultBeeModifier implements IBeeModifier {
return false;
}
public boolean isSelfUnlighted() {
return false;
}
public boolean isSunlightSimulated() {
return false;
}
@@ -54,10 +54,17 @@ public interface IBeeModifier {
boolean isSealed();
/**
* @return Boolean indicating if housing can ignore darkness/night
* @return Boolean indicating if housing can ignore darkness/night. Cannot be used together with SelfUnlighted
*/
boolean isSelfLighted();
/**
* @return Boolean indicating if housing can ignore lightness/day. Cannot be used together with SelfLighted
*/
default boolean isSelfUnlighted() {
return false;
}
/**
* @return Boolean indicating if housing can ignore not seeing the sky
*/
@@ -5,7 +5,12 @@
******************************************************************************/
package forestry.api.apiculture;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
public interface IHiveFrame {
@@ -22,4 +27,15 @@ public interface IHiveFrame {
ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear);
IBeeModifier getBeeModifier();
/**
* Provides an override for the "Hold Shift" tooltip info for a frame.<br>
* Called by {@link forestry.apiculture.EventHandlerApiculture#addFrameTooltip(ItemTooltipEvent)}.
*
* @return The info to display for this frame, or null if default generated info.
*/
@Nullable
default List<String> getFrameTooltip() {
return null;
}
}
@@ -10,6 +10,7 @@ import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.authlib.GameProfile;
import forestry.api.world.ITreeGenData;
/**
@@ -12,11 +12,15 @@ public interface IClimateControlled {
/**
* Change the temperature, but not lower than boundaryDown or higher than boundaryUp.
*
* When used in an alveary the change applies a 20x stronger effect
*/
void addTemperatureChange(float change, float boundaryDown, float boundaryUp);
/**
* Change the humidity, but not lower than boundaryDown or higher than boundaryUp.
*
* When used in an alveary the change applies a 20x stronger effect
*/
void addHumidityChange(float change, float boundaryDown, float boundaryUp);
}
@@ -34,7 +34,8 @@ public enum FarmDirection {
return SOUTH;
case WEST:
return WEST;
default:
return null;
}
return null;
}
}
@@ -9,33 +9,37 @@ import net.minecraft.item.ItemStack;
public class RainSubstrate {
public enum WeatherState {
CLEAR,
RAIN,
STORM
}
/**
* Rain substrate capable of activating the rainmaker.
*/
public ItemStack item;
/**
* Duration of the rain shower triggered by this substrate in Minecraft ticks.
* Duration of the weather event triggered by this substrate in Minecraft ticks.
*/
public int duration;
/**
* Speed of activation sequence triggered.
*/
public float speed;
/**
* The type of weather triggered.
*/
public WeatherState weather;
public boolean reverse;
public RainSubstrate(ItemStack item, int duration, float speed) {
this(item, duration, speed, false);
public RainSubstrate(ItemStack item, float speed, WeatherState weather) {
this(item, 0, speed, weather);
}
public RainSubstrate(ItemStack item, float speed) {
this(item, 0, speed, true);
}
public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) {
public RainSubstrate(ItemStack item, int duration, float speed, WeatherState weather) {
this.item = item;
this.duration = duration;
this.speed = speed;
this.reverse = reverse;
this.weather = weather;
}
}
@@ -11,6 +11,7 @@ import java.util.Map;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IClassification.EnumClassLevel;
/**
@@ -52,4 +52,8 @@ public interface IIndividual extends INBTTagable {
IIndividual copy();
boolean isPureBred(IChromosomeType chromosomeType);
default void addLore(List<String> text) {}
default void addDiscoveredBy(List<String> text) {}
}
@@ -6,6 +6,7 @@
package forestry.api.mail;
import com.mojang.authlib.GameProfile;
import forestry.api.core.INBTTagable;
public interface IMailAddress extends INBTTagable {
@@ -49,6 +49,14 @@ public interface IAlvearyComponent<T extends IMultiblockLogicAlveary> extends IM
* @param alveary the climate controlled alveary
*/
void changeClimate(int tickCount, IClimateControlled alveary);
/**
* Get the priority of this climatiser. Called when alveary is constructed.
* {@link #changeClimate(int, IClimateControlled)} are run in descending priority.
*/
default int getPriority() {
return 0;
}
}
/**
@@ -9,6 +9,8 @@ import net.minecraft.util.ChunkCoordinates;
import com.mojang.authlib.GameProfile;
import forestry.core.inventory.IInventoryAdapter;
/**
* Basic interface for a multiblock machine component. Implemented by TileEntities.
*/
@@ -45,4 +47,15 @@ public interface IMultiblockComponent {
* Called when the machine is broken for game reasons, e.g. a player removed a block or an explosion occurred.
*/
void onMachineBroken();
/**
* A component with a separate inventory, like the Alveary Swarmer or Alveary Sieve.
*/
interface HasInventory {
/**
* Called when this part is destroyed to drop its contents.
*/
IInventoryAdapter getInternalInventory();
}
}
@@ -9,6 +9,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.ITreeGenome;
public interface ITreeGenData {
@@ -15,6 +15,6 @@ public class ApiaryBeeModifier extends DefaultBeeModifier {
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return 0.1f;
return -0.9f; // results in 0.1 with no frames, see BeeHousingModifier,java
}
}
@@ -49,9 +49,10 @@ public class BeeHousingModifier implements IBeeModifier {
@Override
public float getProductionModifier(IBeeGenome genome, final float currentModifier) {
float modifierValue = 1.0f;
float modifierValue = 0.0f; // part of the additive production nerf, but don't worry at least you effectively
// get +1 from `t` in `Bee.java:produceStacks`
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
modifierValue *= modifier.getProductionModifier(genome, modifierValue * currentModifier);
modifierValue += modifier.getProductionModifier(genome, modifierValue + currentModifier);
}
return modifierValue;
}
@@ -94,6 +95,16 @@ public class BeeHousingModifier implements IBeeModifier {
return false;
}
@Override
public boolean isSelfUnlighted() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
if (modifier.isSelfUnlighted()) {
return true;
}
}
return false;
}
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
@@ -20,7 +20,7 @@ public class BeehouseBeeModifier extends DefaultBeeModifier {
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return 0.25f;
return -0.75f;// results in 0.25 with no frames, see BeeHousingModifier,java
}
@Override
@@ -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();
@@ -0,0 +1,125 @@
package forestry.apiculture;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IHiveFrame;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
public class EventHandlerApiculture {
@SubscribeEvent
public void addFrameTooltip(ItemTooltipEvent event) {
ItemStack itemStack = event.itemStack;
if (itemStack != null && itemStack.getItem() instanceof IHiveFrame) {
IHiveFrame frame = (IHiveFrame) itemStack.getItem();
IBeeModifier modifier = frame.getBeeModifier();
List<String> tooltip = event.toolTip;
if (!Proxies.common.isShiftDown()) {
tooltip.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">");
} else {
if (frame.getFrameTooltip() != null) {
// use the override if it exists
tooltip.addAll(frame.getFrameTooltip());
} else {
// otherwise use the auto-generated info
int durability = itemStack.getMaxDamage();
tooltip.add(StringUtil.localize("frame.tooltip.durability") + getDurabilityFormatted(durability));
float territory = modifier.getTerritoryModifier(null, 1.0F);
tooltip.add(
StringUtil.localize("frame.tooltip.territory")
+ getModifierFormatted(territory, false, false));
float mutation = modifier.getMutationModifier(null, null, 1.0F);
tooltip.add(
StringUtil.localize("frame.tooltip.mutationRate")
+ getModifierFormatted(mutation, false, false));
float lifespan = modifier.getLifespanModifier(null, null, 1.0F);
// lower lifespan is better
tooltip.add(
StringUtil.localize("frame.tooltip.lifespan")
+ getModifierFormatted(lifespan, false, true));
float production = modifier.getProductionModifier(null, 0.0F);
tooltip.add(
StringUtil.localize("frame.tooltip.production")
+ getModifierFormatted(production, true, false));
float flowering = modifier.getFloweringModifier(null, 1.0F);
tooltip.add(
StringUtil.localize("frame.tooltip.flowering")
+ getModifierFormatted(flowering, false, false));
float decay = modifier.getGeneticDecay(null, 1.0F);
// lower genetic decay is better
tooltip.add(
StringUtil.localize("frame.tooltip.geneticDecay")
+ getModifierFormatted(decay, false, true));
}
}
}
}
private static String getDurabilityFormatted(int durability) {
EnumChatFormatting color;
if (durability < 100) {
color = EnumChatFormatting.DARK_RED;
} else if (durability < 200) {
color = EnumChatFormatting.RED;
} else if (durability < 250) {
color = EnumChatFormatting.GOLD;
} else if (durability < 750) {
color = EnumChatFormatting.GREEN;
} else {
color = EnumChatFormatting.AQUA;
}
return color + " " + durability;
}
private static String getModifierFormatted(float value, boolean additive, boolean undesireable) {
EnumChatFormatting color;
float lo_threshold = 0.5F, mid_threshold = 1.0F, hi_threshold = 2.0F;
float discriminant = value;
if (additive) {
lo_threshold = -1.0F;
mid_threshold = 0.0F;
hi_threshold = 2.0F; // this one is the same
if (undesireable) {
discriminant = -value;
}
} else if (undesireable) {
discriminant = 1.0F / value;
}
if (discriminant <= lo_threshold) {
color = EnumChatFormatting.DARK_RED; // "bad" stat
} else if (discriminant < mid_threshold) {
color = EnumChatFormatting.RED; // "below average" stat
} else if (discriminant == mid_threshold) {
color = EnumChatFormatting.GOLD; // "average" stat
} else if (discriminant <= hi_threshold) {
color = EnumChatFormatting.GREEN; // "above average" stat
} else {
color = EnumChatFormatting.AQUA; // "great" stat
}
String formatted = color.toString();
// Set symbol for if this value is additive or multiplicative
if (!additive) {
formatted += " x";
} else if (value >= 0.0F) {
formatted += " +";
} else {
formatted += " "; // the "-" will be applied, but we still need a space or minecraft will crash
}
// trim trailing zeroes if no decimal-precision is needed
if (value == (long) value) {
return formatted + (long) value;
}
return formatted + value;
}
}
@@ -8,7 +8,10 @@
******************************************************************************/
package forestry.apiculture;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
@@ -73,4 +76,27 @@ public class InventoryBeeHousing extends InventoryAdapterRestricted implements I
public final boolean addProduct(ItemStack product, boolean all) {
return InventoryUtil.tryAddStack(this, product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
}
public void dumpInventoryIntoWorld(World world, ChunkCoordinates coordinates) {
if (world.isRemote) {
return;
}
for (int i = 0; i < SLOT_PRODUCT_COUNT; i++) {
ItemStack stack = getStackInSlot(i);
if (stack == null) {
continue;
}
setInventorySlotContents(i, null);
EntityItem entityitem = new EntityItem(
world,
coordinates.posX + 0.5,
coordinates.posY + 0.5,
coordinates.posZ + 0.5,
stack);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
}
}
@@ -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);
@@ -14,6 +14,7 @@ import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
import com.google.common.base.Objects;
import forestry.api.genetics.IFlower;
final class Flower implements IFlower {
@@ -213,6 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers,
World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) return false;
Block block = world.getBlock(x, y, z);
final int meta;
@@ -24,7 +24,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual,
int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -39,7 +39,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -34,6 +34,10 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
}
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
@@ -8,6 +8,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
import static forestry.core.utils.MathUtil.safeAdd;
import static forestry.core.utils.MathUtil.safeMultiply;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -15,6 +18,8 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -26,7 +31,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;
@@ -248,7 +266,7 @@ public class Bee extends IndividualLiving implements IBee {
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
if (!canWorkDuringDay(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_NIGHT);
}
} else {
@@ -258,7 +276,7 @@ public class Bee extends IndividualLiving implements IBee {
}
if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay()) {
if (!canWorkDuringDay(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_GLOOMY);
}
} else {
@@ -308,12 +326,16 @@ public class Bee extends IndividualLiving implements IBee {
return errorStates;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkAtNight(IBeeModifier beeModifier) {
return genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted();
return (genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
}
private boolean canWorkDuringDay() {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkDuringDay(IBeeModifier beeModifier) {
return (!genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfUnlighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
}
private boolean canWorkUnderground(IBeeModifier beeModifier) {
@@ -356,6 +378,36 @@ public class Bee extends IndividualLiving implements IBee {
return suitableBiomes;
}
@Override
public void addLore(List<String> text) {
IAlleleBeeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 0) {
String speciesLore = descTokens[0];
if (!speciesLore.isEmpty() && !speciesLore.contains("for.description")) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String formattedLore = EnumChatFormatting.GOLD + speciesLore;
List<String> formattedLoreList = fontRenderer.listFormattedStringToWidth(formattedLore, 200);
text.addAll(formattedLoreList);
}
}
}
@Override
public void addDiscoveredBy(List<String> text) {
IAlleleBeeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 2) {
String discoveredBy = descTokens[2];
if (!discoveredBy.isEmpty()) {
text.add("");
text.add("Discovered by " + EnumChatFormatting.ITALIC + discoveredBy);
}
}
}
@Override
public void addTooltip(List<String> list) {
@@ -451,12 +503,11 @@ public class Bee extends IndividualLiving implements IBee {
// / PRODUCTION
@Override
public ItemStack[] getProduceList() {
ArrayList<ItemStack> products = new ArrayList<>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
products.addAll(primary.getProductChances().keySet());
ArrayList<ItemStack> products = new ArrayList<>(primary.getProductChances().keySet());
Set<ItemStack> secondaryProducts = secondary.getProductChances().keySet();
// Remove duplicates
@@ -475,13 +526,13 @@ public class Bee extends IndividualLiving implements IBee {
}
}
return products.toArray(new ItemStack[products.size()]);
return products.toArray(new ItemStack[0]);
}
@Override
public ItemStack[] getSpecialtyList() {
Set<ItemStack> specialties = genome.getPrimary().getSpecialtyChances().keySet();
return specialties.toArray(new ItemStack[specialties.size()]);
return specialties.toArray(new ItemStack[0]);
}
@Override
@@ -511,9 +562,8 @@ public class Bee extends IndividualLiving implements IBee {
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed();
float prodModifier = beeHousingModifier.getProductionModifier(genome, 1f)
* beeModeModifier.getProductionModifier(genome, 1f);
prodModifier /= 4f;
float prodModifier = beeHousingModifier.getProductionModifier(genome, 0f);
prodModifier += beeModeModifier.getProductionModifier(genome, prodModifier);
// / Primary Products
for (Map.Entry<ItemStack, Float> entry : primary.getProductChances().entrySet()) {
@@ -537,7 +587,7 @@ public class Bee extends IndividualLiving implements IBee {
}
}
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
ItemStack[] productsArray = products.toArray(new ItemStack[0]);
ChunkCoordinates housingCoordinates = housing.getCoordinates();
return genome.getFlowerProvider().affectProducts(
housing.getWorld(),
@@ -549,10 +599,13 @@ public class Bee extends IndividualLiving implements IBee {
}
public static float getFinalChance(float chance, float beeSpeed, float productionModifier, float t) {
if (productionModifier + t <= 0f) {
return 0f;
}
chance *= 100f;
return (float) (((1f + t / 6f) * Math.sqrt(chance) * 2f * (1f + beeSpeed)
+ Math.pow(productionModifier, Math.cbrt(chance))
- 3f) / 100f);
return (float) (2.8 * Math.pow(chance, 0.52)
* Math.pow((productionModifier + t), 0.52)
* Math.pow(beeSpeed, 0.37)) / 100f;
}
/* REPRODUCTION */
@@ -681,9 +734,9 @@ public class Bee extends IndividualLiving implements IBee {
// boost chance for researched mutations
if (breedingTracker.isResearched(beeMutation)) {
float mutationBoost = chance * (Config.researchMutationBoostMultiplier - 1.0f);
float mutationBoost = safeMultiply(chance, Config.researchMutationBoostMultiplier - 1.0f);
mutationBoost = Math.min(Config.maxResearchMutationBoostPercent, mutationBoost);
chance += mutationBoost;
chance = safeAdd(chance, mutationBoost);
}
if (chance > world.rand.nextFloat() * 100) {
@@ -720,6 +773,9 @@ public class Bee extends IndividualLiving implements IBee {
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect blockPos = Vect.add(housingPos, randomPos, offset);
if (!world.blockExists(blockPos.x, blockPos.y, blockPos.z)) {
continue;
}
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
if (tile instanceof IPollinatable) {
@@ -331,7 +331,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SIMMERING, 1), 0.55f)
.addProduct(PluginCore.items.ash.getItemStack(), 0.15f).setTemperature(EnumTemperature.HELLISH)
.addProduct(PluginCore.items.getAsh(), 0.15f).setTemperature(EnumTemperature.HELLISH)
.setHumidity(EnumHumidity.ARID);
}
@@ -8,6 +8,8 @@
******************************************************************************/
package forestry.apiculture.genetics;
import static forestry.core.utils.MathUtil.safeMultiply;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
@@ -49,8 +51,8 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
processedChance *= beeModeModifier.getMutationModifier(genome0, genome1, processedChance);
processedChance = safeMultiply(processedChance, beeHousingModifier.getMutationModifier(genome0, genome1, 1.0F));
processedChance = safeMultiply(processedChance, beeModeModifier.getMutationModifier(genome0, genome1, 1.0F));
return processedChance;
}
@@ -24,11 +24,19 @@ import forestry.api.apiculture.IBeekeepingMode;
public class BeekeepingMode implements IBeekeepingMode {
public static final IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 1.0f, false, false);
public static final IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 1.0f, false, true);
public static final IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 1.0f, false, true);
public static final IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, 0.8f, true, true);
public static final IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, 0.6f, true, true);
public static final IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 0.0f, false, false);// original
// multiplicative
// modifier is
// 1x
public static final IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 0.0f, false, true);// orig 1x
public static final IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 0.0f, false, true);// orig 1x;
// this is the
// default in
// gtnh
public static final IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, -0.2f, true, true);// orig
// 0.8x
public static final IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, -0.4f, true, true);// orig
// 0.6x
private final Random rand;
private final String name;
@@ -93,7 +101,7 @@ public class BeekeepingMode implements IBeekeepingMode {
public boolean isOverworked(IBee queen, IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float productionModifier = beeModifier.getProductionModifier(queen.getGenome(), 1f);
float productionModifier = beeModifier.getProductionModifier(queen.getGenome(), 0f);
if (productionModifier > 16) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.01 * ((productionModifier * productionModifier) - 100)) {
return true;
@@ -13,6 +13,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -21,7 +22,7 @@ import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.multiblock.AlvearyController;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.vect.Vect;
@@ -36,8 +37,13 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
@Override
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
harmEntities(genome, housing);
if (isMobGriefingEnabled(housing)) destroyEnvironment(genome, housing);
return destroyEnvironment(genome, storedData, housing);
return storedData;
}
private boolean isMobGriefingEnabled(IBeeHousing housing) {
return housing.getWorld().getGameRules().getGameRuleBooleanValue("mobGriefing");
}
private void harmEntities(IBeeGenome genome, IBeeHousing housing) {
@@ -56,7 +62,7 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
}
}
private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
private static void destroyEnvironment(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
Random rand = world.rand;
@@ -65,43 +71,66 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
Vect offset = area.multiply(-1 / 2.0f);
Vect posHousing = new Vect(housing.getCoordinates());
boolean isAlveary = housing instanceof AlvearyController;
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(rand, area);
Vect posBlock = randomPos.add(posHousing);
posBlock = posBlock.add(offset);
Vect posBlock = randomPos.add(posHousing).add(offset);
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
// Don't destroy blocks in the protected 3x3x4 area if housing is an Alveary.
// Stops the bee destroying itself. Silly behaviour.
if (isInAlvearyProtectedArea(posHousing, posBlock)) {
continue;
}
// Don't destroy ourselves or blocks below us.
if (posBlock.x == posHousing.x && posBlock.z == posHousing.z && posBlock.y <= posHousing.y) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
// Don't destroy the block directly below the bee.
if (isAlveary) {
if (posBlock.y == posHousing.y - 3) {
continue;
}
} else {
if (posBlock.y == posHousing.y - 1) {
continue;
}
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block instanceof BlockAlveary) {
continue;
}
// Never delete a tile entity. Allows far too much griefing and abuse otherwise.
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (tile instanceof IBeeHousing) {
if (tile != null) {
continue;
}
// Don't let us delete blocks that are not supposed to be breakable by players.
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
continue;
}
// Some mods might use this logic? Idk, just a safety check. Might stop griefing.
EntityPlayer player = world.func_152378_a(housing.getOwner().getId());
if (player == null || !world.canMineBlock(player, posHousing.x, posHousing.y, posHousing.z)) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
break;
}
}
return storedData;
private static boolean isInAlvearyProtectedArea(Vect posHousing, Vect posBlock) {
// Alveary protection area is a 3x3x4 area centered on the top middle, down one block.
int startX = posHousing.x - 1;
int endX = posHousing.x + 1;
int startZ = posHousing.z - 1;
int endZ = posHousing.z + 1;
int startY = posHousing.y - 2;
int endY = posHousing.y + 1;
return posBlock.x >= startX && posBlock.x <= endX
&& posBlock.z >= startZ
&& posBlock.z <= endZ
&& posBlock.y >= startY
&& posBlock.y <= endY;
}
}
@@ -27,6 +27,10 @@ public abstract class AlleleEffectThrottled extends AlleleEffect {
this.requiresWorkingQueen = requiresWorking;
}
public int getThrottle() {
return throttle;
}
@Override
public boolean isCombinable() {
return isCombinable;
@@ -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;
@@ -71,9 +71,8 @@ public class ItemHabitatLocator extends ItemWithGui {
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ);
float temperatureValue = currentBiome
.getFloatTemperature((int) player.posX, (int) player.posY, (int) player.posZ);
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumTemperature temperature = EnumTemperature
.getFromBiome(currentBiome, (int) player.posX, (int) player.posY, (int) player.posZ);
EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall);
list.add(StringUtil.localize("gui.currentBiome") + ": " + currentBiome.biomeName);
@@ -56,7 +56,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return (currentModifier < 10f) ? 2f : 1f;
return (currentModifier < 10.0f) ? 1.0f : 0.0f;
}
@Override
@@ -9,8 +9,10 @@
package forestry.apiculture.multiblock;
import java.io.IOException;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
@@ -59,7 +61,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase
// PARTS
private final Set<IBeeModifier> beeModifiers = new HashSet<>();
private final Set<IBeeListener> beeListeners = new HashSet<>();
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<>();
private final Set<IAlvearyComponent.Climatiser> climatisers = new TreeSet<>(
Comparator.comparingInt(IAlvearyComponent.Climatiser::getPriority).thenComparingInt(Object::hashCode)
.reversed());
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<>();
// CLIENT
@@ -155,6 +159,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase
activeComponents.remove(oldPart);
}
}
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
}
@Override
@@ -233,26 +239,24 @@ public class AlvearyController extends RectangularMultiblockControllerBase
beekeepingLogic.doWork();
}
tempChange = 0;
humidChange = 0;
for (IAlvearyComponent.Climatiser climatiser : climatisers) {
climatiser.changeClimate(tickCount, this);
}
tempChange = equalizeChange(tempChange);
humidChange = equalizeChange(humidChange);
return canWork;
}
private static float equalizeChange(float change) {
if (change == 0) {
return 0;
private float applyChange(float base, float currentChange, float extraChange, float boundaryDown,
float boundaryUp) {
float boundedNewChange = Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp))
- base;
if (extraChange > 0) {
return Math.max(currentChange, boundedNewChange);
} else {
return Math.min(currentChange, boundedNewChange);
}
change *= 0.95f;
if (change <= 0.001f && change >= -0.001f) {
change = 0;
}
return change;
}
@Override
@@ -410,21 +414,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
ChunkCoordinates coordinates = getCoordinates();
float temperature = getBiome().getFloatTemperature(coordinates.posX, coordinates.posY, coordinates.posZ);
tempChange += change;
tempChange = Math.max(boundaryDown - temperature, tempChange);
tempChange = Math.min(boundaryUp - temperature, tempChange);
tempChange = (change > 0 && tempChange < 0) || (change < 0 && tempChange > 0) ? 0 : tempChange;
tempChange = applyChange(temperature, tempChange, change, boundaryDown, boundaryUp);
}
@Override
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
float humidity = getBiome().rainfall;
humidChange += change;
humidChange = Math.max(boundaryDown - humidity, humidChange);
humidChange = Math.min(boundaryUp - humidity, humidChange);
humidChange = (change > 0 && humidChange < 0) || (change < 0 && humidChange > 0) ? 0 : humidChange;
humidChange = applyChange(humidity, humidChange, change, boundaryDown, boundaryUp);
}
/* GUI */
@@ -32,7 +32,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
@Override
public float getBoundaryDown() {
return 0.05f;
return -1f;
}
@Override
@@ -22,12 +22,12 @@ public class TileAlvearyHeater extends TileAlvearyClimatiser {
@Override
public float getChangePerTransfer() {
return 0.01f;
return 0.015f;
}
@Override
public float getBoundaryUp() {
return 2.5f;
return 3.5f;
}
@Override
@@ -19,6 +19,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import forestry.api.core.IClimateControlled;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
import forestry.apiculture.gui.GuiAlvearyHygroregulator;
@@ -31,8 +32,8 @@ import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.tiles.ILiquidTankTile;
public class TileAlvearyHygroregulator extends TileAlveary
implements IInventory, ILiquidTankTile, IFluidHandler, IAlvearyComponent.Climatiser {
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IFluidHandler,
IAlvearyComponent.Climatiser, IMultiblockComponent.HasInventory {
private final HygroregulatorRecipe[] recipes;
@@ -56,9 +57,9 @@ public class TileAlvearyHygroregulator extends TileAlveary
this.tankManager = new TankManager(this, liquidTank);
this.recipes = new HygroregulatorRecipe[] {
new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.01f) };
}
@Override
@@ -111,6 +112,11 @@ public class TileAlvearyHygroregulator extends TileAlveary
}
}
@Override
public int getPriority() {
return 100;
}
/* SAVING & LOADING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -18,6 +18,7 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearySieve;
import forestry.apiculture.gui.GuiAlvearySieve;
@@ -25,7 +26,8 @@ import forestry.apiculture.inventory.InventoryAlvearySieve;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
public class TileAlvearySieve extends TileAlveary implements IAlvearyComponent.BeeListener {
public class TileAlvearySieve extends TileAlveary
implements IAlvearyComponent.BeeListener, IMultiblockComponent.HasInventory {
private final IBeeListener beeListener;
private final InventoryAlvearySieve inventory;
@@ -8,8 +8,9 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
@@ -21,6 +22,7 @@ import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearySwarmer;
import forestry.apiculture.gui.GuiAlvearySwarmer;
@@ -36,10 +38,11 @@ import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ItemStackUtil;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
public class TileAlvearySwarmer extends TileAlveary
implements ISidedInventory, IActivatable, IAlvearyComponent.Active, IMultiblockComponent.HasInventory {
private final InventorySwarmer inventory;
private final Stack<ItemStack> pendingSpawns = new Stack<>();
private final Deque<ItemStack> pendingSpawns = new ArrayDeque<>();
private boolean active;
public TileAlvearySwarmer() {
@@ -15,11 +15,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.apiculture.blocks.BlockCandle;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.proxy.Proxies;
@ThreadSafeISBRH(perThread = false)
public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
@Override
@@ -58,7 +61,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
int colour = tileCandle.getColour();
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double d0 = 0.4000000059604645D;
@@ -87,7 +90,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10,
int colour) {
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
double maxU = icon.getMaxU();
@@ -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) {
@@ -16,6 +16,8 @@ import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -298,6 +300,36 @@ public class Tree extends Individual implements ITree, IPlantable {
return plantTypes;
}
@Override
public void addLore(List<String> text) {
IAlleleTreeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 0) {
String speciesLore = descTokens[0];
if (!speciesLore.isEmpty() && !speciesLore.contains("for.description")) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String formattedLore = EnumChatFormatting.GOLD + speciesLore;
List<String> formattedLoreList = fontRenderer.listFormattedStringToWidth(formattedLore, 200);
text.addAll(formattedLoreList);
}
}
}
@Override
public void addDiscoveredBy(List<String> text) {
IAlleleTreeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 2) {
String discoveredBy = descTokens[2];
if (!discoveredBy.isEmpty()) {
text.add("");
text.add("Discovered by " + EnumChatFormatting.ITALIC + discoveredBy);
}
}
}
@Override
public void addTooltip(List<String> list) {
@@ -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);
@@ -1146,6 +1148,14 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
return species.getUID();
}
public EnumWoodType getWoodType() {
return woodType;
}
public ItemStack getVanillaWood() {
return vanillaWood;
}
@Override
public final ITreeGenome getGenome() {
return genome;
@@ -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();
@@ -12,6 +12,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.authlib.GameProfile;
import forestry.api.world.ITreeGenData;
public class TreeBlockTypeLeaf implements ITreeBlockType {
@@ -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);
@@ -8,6 +8,8 @@
******************************************************************************/
package forestry.core.blocks;
import static forestry.Forestry.isDreamcraftLoaded;
import java.util.ArrayList;
import java.util.List;
@@ -52,7 +54,7 @@ public class BlockResourceOre extends Block {
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int metadata, float par6, int par7) {
super.dropBlockAsItemWithChance(world, x, y, z, metadata, par6, par7);
if (metadata == 0) {
if (metadata == 0 && !isDreamcraftLoaded) {
this.dropXpOnBlockBreak(world, x, y, z, MathHelper.getRandomIntegerInRange(world.rand, 1, 4));
}
}
@@ -61,7 +63,7 @@ public class BlockResourceOre extends Block {
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
if (metadata == ResourceType.APATITE.ordinal()) {
if (metadata == ResourceType.APATITE.ordinal() && !isDreamcraftLoaded) {
int fortuneModifier = world.rand.nextInt(fortune + 2) - 1;
if (fortuneModifier < 0) {
fortuneModifier = 0;
@@ -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);
}
}
}
@@ -125,6 +116,12 @@ public abstract class BlockStructure extends BlockForestry {
InventoryUtil.dropSockets((ISocketable) tile, world, x, y, z);
}
}
if (tile instanceof IMultiblockComponent.HasInventory) {
IMultiblockComponent.HasInventory hasInventory = (IMultiblockComponent.HasInventory) tile;
InventoryUtil.dropInventory(hasInventory.getInternalInventory(), world, x, y, z);
}
}
super.breakBlock(world, x, y, z, block, meta);
}
@@ -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;
@@ -31,6 +33,7 @@ import forestry.mail.gui.GuiMailboxInfo;
public class Config {
public static boolean disableButterfly;
public static final String CATEGORY_COMMON = "common";
public static final String CATEGORY_FLUIDS = "fluids";
@@ -96,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;
@@ -103,6 +137,7 @@ public class Config {
public static boolean enableHints = true;
public static final LinkedListMultimap<String, String> hints = LinkedListMultimap.create();
public static boolean enableEnergyStat = true;
public static boolean showBackpackDurability = true;
public static boolean isStructureEnabled(String uid) {
return !Config.disabledStructures.contains(uid);
@@ -146,6 +181,8 @@ public class Config {
configCommon = new LocalizedConfiguration(configFileCommon, "1.2.0");
disableButterfly = configCommon.getBooleanLocalized("mobs", "disable.butterfly", false);
gameMode = configCommon
.getStringLocalized("difficulty", "game.mode", "EASY", new String[] { "OP, EASY, NORMAL, HARD" });
@@ -265,6 +302,9 @@ public class Config {
configCommon.moveProperty("tweaks.gui", "mail.alert", "tweaks.gui.mail.alert");
configCommon.renameProperty("tweaks.gui.mail.alert", "mail.alert", "enabled");
showBackpackDurability = configCommon
.getBooleanLocalized("tweaks.gui", "showBackpackDurability", showBackpackDurability);
mailAlertEnabled = configCommon.getBooleanLocalized("tweaks.gui.mail.alert", "enabled", mailAlertEnabled);
mailAlertXPosition = configCommon.getEnumLocalized(
"tweaks.gui.mail.alert",
@@ -276,6 +316,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);
@@ -383,4 +428,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;
@@ -108,6 +109,7 @@ public class Constants implements IForestryConstants {
public static final int MACHINE_MAX_ENERGY = 5000;
public static final int RAINMAKER_RAIN_DURATION_IODINE = 10000;
public static final int RAINMAKER_RAIN_DURATION_PHOSPHORICIODINE = 10000;
public static final int STILL_DESTILLATION_DURATION = 100;
public static final int STILL_DESTILLATION_INPUT = 10;
@@ -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) {
@@ -72,6 +72,12 @@ public abstract class ItemGE extends ItemForestry {
if (individual.isAnalyzed()) {
if (Proxies.common.isShiftDown()) {
individual.addTooltip(list);
individual.addDiscoveredBy(list);
if (Proxies.common.isCtrlDown()) {
individual.addLore(list);
} else {
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tml") + ">");
}
} else {
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">");
}
@@ -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;
}
@@ -172,4 +176,8 @@ public abstract class Mutation implements IMutationCustom {
public boolean isSecret() {
return isSecret;
}
public List<IMutationCondition> getMutationConditions() {
return mutationConditions;
}
}
@@ -53,4 +53,13 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
inventory.onSlotClick(player);
return result;
}
@Override
public void detectAndSendChanges() {
if (!inventory.isParentItemEquipped()) {
inventory.getPlayer().closeScreen();
return;
}
super.detectAndSendChanges();
}
}
@@ -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) {
Loaded 100 of 232 files, more files were not shown because too many files have changed in this diff. Show more