Compare commits

...
97 Commits
Author SHA1 Message Date
Firewooddoge 4b310d407f Fix other-language block names showing as unlocalized .name keys (#132) 2026-10-25 10:55:33 +01:00
Worive f2e85073d3 Fix alveary inventory drops on chunk unload (#134) 2026-10-03 12:46:01 -05:00
ABKQPO 0bd9a7978a Expose mutation resource condition values (#135) 2026-09-15 21:06:15 +02:00
boubou19 e47fc90433 reduce allocations of arrays to once per call (#133) 2026-08-25 19:19:42 -04:00
boubou19 452064ef1d More enum .values() caching (#131) 2026-08-14 01:10:34 +02:00
boubou19 59c8c36520 Cache enum .values() (#130) 2026-08-10 20:56:48 +02:00
Ryan Nasers ea1c4edae4 Fixes the display of blocks in NEI for the double slab blocks (#129) 2026-08-10 08:22:57 +07:00
Firewooddoge 4c46626cdb Fix Japanese block names showing as unlocalized .name keys (#128) 2026-08-08 14:30:36 +07:00
Alex VermetteandAlex Vermette d6fa8d8b74 fix: implement stacked block slab (#127)
Co-authored-by: Alex Vermette <vermz@hotmail.ca>
2026-07-27 13:20:40 -04:00
UltraProdigy 704861b666 Delete Forestry CONTRIBUTING.md (#126) 2026-07-04 19:02:06 +00:00
Algent db25dcce48 Dupe Fix - Make bag logic more lag resistant (#121) 2026-07-04 18:57:41 +00:00
FourIsTheNumber 4b364a93db Use extended interface (#125) 2026-07-01 18:27:50 -04:00
Yannick Marcotte-Gourde a217884480 Fix Worktable NEI fill regression (#124) 2026-06-28 15:19:53 -04:00
tiffit 90f7c36a1e Add NEI overlays for the carpenter and fabricator (#123) 2026-06-19 21:58:09 +02:00
FourIsTheNumber 974e44f5cd Add API method for protection amount on IArmorApiarist (#122) 2026-06-15 01:19:34 -04:00
Ed Rakhmankulov bbb374cd5e added ability to open backpacks enabled by NoHotbarNeeded (#105) 2026-05-24 14:59:08 +02:00
Eldrinn-Elantey 3470c6c7d1 Add OreDictionary entry for fertile tree pollen (#120) 2026-05-09 14:26:25 +02:00
Alexdoru b1377d5642 return the correct butterfly when rendering (#119) 2026-05-01 17:36:27 +02:00
Yoshy b50910496e Fix crash when rendering creative tab (#118) 2026-05-01 00:39:25 -04:00
AlexdoruandUltraProdigy cc4b16e2a5 fix crash if block is null in TileWood#getPickBlock (#114)
Co-authored-by: UltraProdigy <187078471+UltraProdigy@users.noreply.github.com>
2026-04-28 22:19:46 +00:00
Faltsolph 3b63133790 change an integer to a float in a division to avoid possible rounding error in apiary comb production formula (#117) 2026-04-28 21:29:29 +00:00
Alexdoruandboubou19 6d8d7110e1 Fix world client leaks in butterfly and analyzer renderer (#116)
Co-authored-by: boubou19 <miisterunknown@gmail.com>
2026-04-27 23:43:29 +02:00
Martin Robertz 98fa57844e update 2026-04-27 12:42:21 +02:00
Ranzu adbb300523 Added color localization for the missing items inside the worktable gui (#115) 2026-04-25 16:16:40 +02:00
Alexdoru 839882b783 Fix WorldClient memory leak in butterfly renderer (#113) 2026-04-09 21:49:41 +02:00
Martin Robertz 2635d036aa update+gradle+deps+bs 2026-04-03 16:23:52 +02:00
Guillaume Mercier cf8f2f54c5 Add fertilizer registry (#112) 2026-04-01 20:02:06 +02:00
4844bc937b Fix alveary climate change calculations (#109)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: UltraProdigy <187078471+UltraProdigy@users.noreply.github.com>
2026-03-14 08:12:51 +00:00
Alexdoru 88f50d91e1 BFS leaf decay (#111) 2026-03-13 16:50:52 +01:00
Alexdoru 3bc6720dec Prevent loading chunks while ticking blocks (#110) 2026-03-12 21:33:00 +01:00
UltraProdigy 1083f52a30 Optimize Image & Workflow (#108) 2026-03-07 10:30:44 +01:00
Alexdoru 3fb58ad6a5 Cache frequent Enum#values() calls (#107) 2026-03-03 21:22:36 +01:00
Martin Robertz 7e1398438d update 2026-02-21 23:38:35 +01:00
Ranzu a02df943ed Work on localization and color properties (#106) 2026-02-21 23:33:53 +01:00
CN_132DAS f88742e7ab Allow bees use EFR flowers (#104) 2025-12-14 19:54:18 +01:00
Martin Robertz fb2ff8aef3 update 2025-11-04 22:38:13 +01:00
3f41c5e8f8 Add null guards to BlockUtil reflections to prevent NullPointerExceptions (#103)
Co-authored-by: Teteros <Teteros@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
2025-11-04 21:39:04 +01:00
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 <dream-master@gmx.net>
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 <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
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 <noreply@combuster.nl>
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 <dream-master@gmx.net>
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 <54497873+GTNH-Colen@users.noreply.github.com>
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
403 changed files with 2872 additions and 1239 deletions

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
name: Optimize images
on:
pull_request:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
push:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
jobs:
optimize-images:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
secrets: inherit
+1
View File
@@ -30,3 +30,4 @@ src/main/resources/mixins.*.json
*.bat
*.DS_Store
!gradlew.bat
layout.json
-29
View File
@@ -1,29 +0,0 @@
How to submit a bug report to Forestry
====================================
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
If you can, see if the bug still happens with the latest unstable build.
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
For crashes, you must post a link to the full crash report.
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
Thank you for reporting bugs!
How to contribute to Forestry
====================================
### Contributor License Agreement
Before pull requests can be accepted, the contributor needs to sign a contributor license agreement. (Essentially giving a license for using his code and/or media and for re-licensing it, for details read the agreement linked below.)
### How do I sign?
To keep the hassle for everyone involved to a minimum, Forestry uses CLAHub to manage the agreements. To get started, <a href="https://www.clahub.com/agreements/ForestryMC/ForestryMC">sign the Contributor License Agreement</a>.
### Why is this needed?
Without CLAs it at some point becomes essentially impossible to change the license of a project which accepts contributions from third parties. Without an explicit agreement every contributor would still own the copyright to his code. So as long as it (or parts of it) remain in the code base, he would have to agree to every license change. If enough time has passed, there may be dozens, perhaps even hundreds of contributors involved and it will be very hard to track down each and every one of them and get them to agree on a new license.
This would make it impossible to change the license to a more permissive one at a later date, so the code would be locked into CC BY-NC-ND 3.0 until it passes into the public domain about a hundred years from now. This situation is to be avoided and that’s why you are being bothered with this CLA.
+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.
+6 -3
View File
@@ -1,10 +1,13 @@
// Add your dependencies here
dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
api('curse.maven:cofh-lib-220333:2388748')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.5.3-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.6.1:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.38:api')
compileOnlyApi('com.github.GTNewHorizons:Angelica:2.1.19:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.107-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:craftguide-75557:2459320')
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
}
+58 -11
View File
@@ -14,7 +14,7 @@ modId = Forestry
modGroup = forestry
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
@@ -33,15 +33,39 @@ channel = stable
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
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
# 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 modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# 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.
@@ -61,6 +85,9 @@ 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";
@@ -77,18 +104,25 @@ apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
accessTransformersFile = forestry_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# 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!
@@ -114,16 +148,22 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_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/
# 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.
#
@@ -137,7 +177,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# 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.
@@ -158,6 +198,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# 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.
@@ -188,4 +234,5 @@ curseForgeRelations =
# ideaCheckSpotlessOnBuild = true
# Non-GTNH properties
gradleTokenGroupName =
org.gradle.configuration-cache = true
org.gradle.parallel = true
+12
View File
@@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainVersion=25
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+7 -8
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -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/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -112,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -170,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -203,15 +203,14 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+3 -2
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 ##########################################################################
@@ -68,11 +70,10 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1
View File
@@ -1,4 +1,5 @@
// Add any additional repositiroes for your dependencies here
repositories {
mavenLocal()
}
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
}
+7 -1
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;
@@ -56,7 +57,8 @@ import forestry.plugins.PluginManager;
name = Constants.MOD,
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[10.13.4.1566,);" + "after:Buildcraft|Core@[6.1.7,);"
dependencies = "required-after:Forge@[10.13.4.1566,);" + "required-after:gtnhlib@[0.9.41,);"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
@@ -79,11 +81,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);
@@ -84,7 +84,12 @@ public enum EnumBeeChromosome implements IChromosomeType {
*/
EFFECT(IAlleleBeeEffect.class);
Class<? extends IAllele> clss;
final Class<? extends IAllele> clss;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumBeeChromosome[] VALUES = values();
EnumBeeChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
@@ -17,9 +17,12 @@ public enum EnumBeeType implements ISpeciesType {
LARVAE,
NONE;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumBeeType[] VALUES = values();
String name;
private final String name;
EnumBeeType() {
this.name = this.toString().toLowerCase(Locale.ENGLISH);
@@ -28,4 +31,8 @@ public enum EnumBeeType implements ISpeciesType {
public String getName() {
return name;
}
public static EnumBeeType fromOrdinal(int ordinal) {
return VALUES[ordinal];
}
}
@@ -0,0 +1,20 @@
package forestry.api.apiculture;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IArmorApiaristMulti extends IArmorApiarist {
/**
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
* act as full protection.
*
* @param entity Entity being attacked
* @param armor Armor item
* @param cause Optional cause of attack, such as a bee effect identifier
* @return Amount of effective protected slots
*/
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
return 1;
}
}
@@ -73,9 +73,14 @@ public enum EnumTreeChromosome implements IChromosomeType {
/**
* Determines if the tree can burn.
*/
FIREPROOF(IAlleleBoolean.class),;
FIREPROOF(IAlleleBoolean.class);
Class<? extends IAllele> clss;
final Class<? extends IAllele> clss;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumTreeChromosome[] VALUES = values();
EnumTreeChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
@@ -17,9 +17,14 @@ public enum EnumHumidity {
NORMAL("Normal"),
DAMP("Damp");
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumHumidity[] VALUES = values();
public final String name;
private EnumHumidity(String name) {
EnumHumidity(String name) {
this.name = name;
}
@@ -27,10 +27,15 @@ public enum EnumTemperature {
HOT("Hot", "habitats/desert"),
HELLISH("Hellish", "habitats/nether");
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumTemperature[] VALUES = values();
public final String name;
public final String iconIndex;
private EnumTemperature(String name, String iconIndex) {
EnumTemperature(String name, String iconIndex) {
this.name = name;
this.iconIndex = iconIndex;
}
@@ -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);
}
@@ -16,6 +16,11 @@ public enum FarmDirection {
private final ForgeDirection forgeDirection;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final FarmDirection[] VALUES = values();
FarmDirection(ForgeDirection forgeDirection) {
this.forgeDirection = forgeDirection;
}
@@ -25,17 +30,16 @@ public enum FarmDirection {
}
public static FarmDirection getFarmDirection(ForgeDirection forgeDirection) {
switch (forgeDirection) {
case NORTH:
return NORTH;
case EAST:
return EAST;
case SOUTH:
return SOUTH;
case WEST:
return WEST;
default:
return null;
}
return switch (forgeDirection) {
case NORTH -> NORTH;
case EAST -> EAST;
case SOUTH -> SOUTH;
case WEST -> WEST;
default -> null;
};
}
public static FarmDirection fromOrdinal(int ordinal) {
return VALUES[ordinal];
}
}
@@ -9,33 +9,37 @@ import net.minecraft.item.ItemStack;
public class RainSubstrate {
public enum WeatherState {
CLEAR,
RAIN,
STORM
}
/**
* Rain substrate capable of activating the rainmaker.
*/
public ItemStack item;
/**
* Duration of the rain shower triggered by this substrate in Minecraft ticks.
* Duration of the weather event triggered by this substrate in Minecraft ticks.
*/
public int duration;
/**
* Speed of activation sequence triggered.
*/
public float speed;
/**
* The type of weather triggered.
*/
public WeatherState weather;
public boolean reverse;
public RainSubstrate(ItemStack item, int duration, float speed) {
this(item, duration, speed, false);
public RainSubstrate(ItemStack item, float speed, WeatherState weather) {
this(item, 0, speed, weather);
}
public RainSubstrate(ItemStack item, float speed) {
this(item, 0, speed, true);
}
public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) {
public RainSubstrate(ItemStack item, int duration, float speed, WeatherState weather) {
this.item = item;
this.duration = duration;
this.speed = speed;
this.reverse = reverse;
this.weather = weather;
}
}
@@ -52,4 +52,8 @@ public interface IIndividual extends INBTTagable {
IIndividual copy();
boolean isPureBred(IChromosomeType chromosomeType);
default void addLore(List<String> text) {}
default void addDiscoveredBy(List<String> text) {}
}
@@ -77,7 +77,12 @@ public enum EnumButterflyChromosome implements IChromosomeType {
*/
TERRITORY(IAlleleArea.class),;
Class<? extends IAllele> clss;
final Class<? extends IAllele> clss;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumButterflyChromosome[] VALUES = values();
EnumButterflyChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
@@ -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;
}
}
/**
@@ -0,0 +1,40 @@
package forestry.api.multiblock;
import java.util.Collection;
import net.minecraft.item.ItemStack;
public interface IFarmFertilizerRegistry {
/**
* Gets a list of all fertilizer stacks in the registry.
*
* @return The current fertilizer registry.
*/
Collection<ItemStack> getFertilizers();
/**
* Adds a new fertilizer to the registry.
*
* @apiNote The stack size doesn't matter it always consumes 1.
* @apiNote You can use OreDictionary.WILDCARD_VALUE to specific that any meta of the item will be ok.
*
* @param itemstack The item to add to the registry.
*/
void addFertilizer(ItemStack itemstack);
/**
* Removes a fertilizer from the fretilizer registry.
*
* @param itemstack The item to remove from the registry.
*/
void removeFertilizer(ItemStack itemstack);
/**
* Checks if an item is a usable multi-farm fertilizer.
*
* @param itemstack - The stack to check with.
* @return True if the item is a fertilizer item.
*/
boolean isFertilizer(ItemStack itemstack);
}
@@ -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();
}
}
@@ -8,4 +8,6 @@ package forestry.api.multiblock;
public class MultiblockManager {
public static IMultiblockLogicFactory logicFactory;
public static IFarmFertilizerRegistry farmFertilizerRegistry;
}
@@ -15,26 +15,20 @@ import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.apiculture.IArmorApiaristHelper;
import forestry.api.apiculture.IArmorApiaristMulti;
public class ArmorApiaristHelper implements IArmorApiaristHelper {
@Override
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
if (stack == null) {
return false;
}
Item item = stack.getItem();
if (!(item instanceof IArmorApiarist)) {
return false;
}
if (stack == null || !(stack.getItem() instanceof IArmorApiarist armor)) return false;
IArmorApiarist armorApiarist = (IArmorApiarist) item;
try {
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
return armor.protectEntity(entity, stack, cause, doProtect);
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
if (entity instanceof EntityPlayer) {
return armorApiarist.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
return armor.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
} else {
return true; // fallback on assuming IArmorApiarist will protect the entity
}
@@ -48,11 +42,13 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
for (int i = 1; i <= 4; i++) {
ItemStack armorItem = entity.getEquipmentInSlot(i);
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
count++;
Item item = armorItem.getItem();
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
else count++;
}
}
return count;
return Math.min(count, 4);
}
@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();
@@ -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;
}
@@ -38,7 +38,7 @@ public class CommandBeeGive extends SubCommand {
setPermLevel(PermLevel.ADMIN);
List<String> beeTypeStrings = new ArrayList<>();
for (EnumBeeType type : EnumBeeType.values()) {
for (EnumBeeType type : EnumBeeType.VALUES) {
if (type == EnumBeeType.NONE) {
continue;
}
@@ -166,7 +166,7 @@ public class CommandBeeGive extends SubCommand {
}
private static EnumBeeType getBeeType(String beeTypeName) {
for (EnumBeeType beeType : EnumBeeType.values()) {
for (EnumBeeType beeType : EnumBeeType.VALUES) {
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
return beeType;
}
@@ -213,6 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers,
World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) return false;
Block block = world.getBlock(x, y, z);
final int meta;
@@ -24,7 +24,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual,
int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -39,7 +39,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
return false;
}
@@ -34,6 +34,10 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
}
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
@@ -8,6 +8,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
import static forestry.core.utils.MathUtil.safeAdd;
import static forestry.core.utils.MathUtil.safeMultiply;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -15,6 +18,8 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -373,6 +378,36 @@ public class Bee extends IndividualLiving implements IBee {
return suitableBiomes;
}
@Override
public void addLore(List<String> text) {
IAlleleBeeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 0) {
String speciesLore = descTokens[0];
if (!speciesLore.isEmpty() && !speciesLore.contains("for.description")) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String formattedLore = EnumChatFormatting.GOLD + speciesLore;
List<String> formattedLoreList = fontRenderer.listFormattedStringToWidth(formattedLore, 200);
text.addAll(formattedLoreList);
}
}
}
@Override
public void addDiscoveredBy(List<String> text) {
IAlleleBeeSpecies primary = genome.getPrimary();
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 2) {
String discoveredBy = descTokens[2];
if (!discoveredBy.isEmpty()) {
text.add("");
text.add("Discovered by " + EnumChatFormatting.ITALIC + discoveredBy);
}
}
}
@Override
public void addTooltip(List<String> list) {
@@ -538,7 +573,7 @@ public class Bee extends IndividualLiving implements IBee {
}
// / Secondary Products
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2, speed, prodModifier, 1f)) {
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2f, speed, prodModifier, 1f)) {
products.add(entry.getKey().copy());
}
}
@@ -699,9 +734,9 @@ public class Bee extends IndividualLiving implements IBee {
// boost chance for researched mutations
if (breedingTracker.isResearched(beeMutation)) {
float mutationBoost = chance * (Config.researchMutationBoostMultiplier - 1.0f);
float mutationBoost = safeMultiply(chance, Config.researchMutationBoostMultiplier - 1.0f);
mutationBoost = Math.min(Config.maxResearchMutationBoostPercent, mutationBoost);
chance += mutationBoost;
chance = safeAdd(chance, mutationBoost);
}
if (chance > world.rand.nextFloat() * 100) {
@@ -738,6 +773,9 @@ public class Bee extends IndividualLiving implements IBee {
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect blockPos = Vect.add(housingPos, randomPos, offset);
if (!world.blockExists(blockPos.x, blockPos.y, blockPos.z)) {
continue;
}
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
if (tile instanceof IPollinatable) {
@@ -148,7 +148,7 @@ public enum BeeBranchDefinition implements IBranchDefinition {
private static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
defaultTemplate = new IAllele[EnumBeeChromosome.VALUES.length];
AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
@@ -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);
}
@@ -102,7 +102,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
IBee bee = (IBee) individual;
Item beeItem;
switch (EnumBeeType.VALUES[type]) {
switch (EnumBeeType.fromOrdinal(type)) {
case QUEEN:
beeItem = PluginApiculture.items.beeQueenGE;
// ensure a queen is always mated
@@ -353,7 +353,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IChromosomeType[] getKaryotype() {
return EnumBeeChromosome.values();
return EnumBeeChromosome.VALUES;
}
@Override
@@ -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;
}
@@ -8,8 +8,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
@@ -22,24 +20,23 @@ import forestry.core.render.TextureManager;
public class DefaultBeeIconProvider implements IBeeIconProvider {
public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider();
private static final IIcon[][] icons = new IIcon[EnumBeeType.VALUES.length][3];
private DefaultBeeIconProvider() {}
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
String beeIconDir = "bees/default/";
IIcon body1 = TextureManager.registerTex(register, beeIconDir + "body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
EnumBeeType beeType = EnumBeeType.values()[i];
for (int i = 0; i < EnumBeeType.VALUES.length; i++) {
EnumBeeType beeType = EnumBeeType.VALUES[i];
if (beeType == EnumBeeType.NONE) {
continue;
}
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
String beeTypeNameBase = beeIconDir + beeType.getName();
icons[i][0] = TextureManager.registerTex(register, beeTypeNameBase + ".outline");
if (beeType == EnumBeeType.LARVAE) {
@@ -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;
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
import forestry.apiculture.gui.GuiBeealyzer;
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.inventory.ItemLocation;
import forestry.core.items.ItemWithGui;
public class ItemBeealyzer extends ItemWithGui {
@@ -24,13 +25,13 @@ public class ItemBeealyzer extends ItemWithGui {
}
@Override
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
return new GuiBeealyzer(player, inventory);
}
@Override
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
return new ContainerAlyzer(inventory, player);
}
@@ -29,6 +29,7 @@ import forestry.apiculture.gui.ContainerHabitatLocator;
import forestry.apiculture.gui.GuiHabitatLocator;
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
import forestry.apiculture.render.TextureHabitatLocator;
import forestry.core.inventory.ItemLocation;
import forestry.core.items.ItemWithGui;
import forestry.core.utils.StringUtil;
@@ -71,9 +72,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);
@@ -82,12 +82,12 @@ public class ItemHabitatLocator extends ItemWithGui {
}
@Override
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
}
@Override
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
}
}
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
import forestry.apiculture.gui.ContainerImprinter;
import forestry.apiculture.gui.GuiImprinter;
import forestry.apiculture.inventory.ItemInventoryImprinter;
import forestry.core.inventory.ItemLocation;
import forestry.core.items.ItemWithGui;
public class ItemImprinter extends ItemWithGui {
@@ -24,12 +25,12 @@ public class ItemImprinter extends ItemWithGui {
}
@Override
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
}
@Override
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
}
}
@@ -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
@@ -107,6 +111,14 @@ public class AlvearyController extends RectangularMultiblockControllerBase
this.readFromNBT(data);
}
@Override
public void detachBlock(IMultiblockComponent part, boolean chunkUnloading) {
if (!chunkUnloading) {
inventory.dumpInventoryIntoWorld(this.worldObj, part.getCoordinates());
}
super.detachBlock(part, chunkUnloading);
}
@Override
protected void onBlockAdded(IMultiblockComponent newPart) {
if (newPart instanceof IAlvearyComponent) {
@@ -233,26 +245,25 @@ 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.round(
(Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp)) - base) * 100)
/ 100.0f;
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
@@ -351,12 +362,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
@Override
public float getExactTemperature() {
ChunkCoordinates coords = getReferenceCoord();
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange;
return Math.round((getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange) * 100)
/ 100.0f;
}
@Override
public float getExactHumidity() {
return getBiome().rainfall + humidChange;
return Math.round((getBiome().rainfall + humidChange) * 100) / 100.0f;
}
@Override
@@ -410,19 +422,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
ChunkCoordinates coordinates = getCoordinates();
float temperature = getBiome().getFloatTemperature(coordinates.posX, coordinates.posY, coordinates.posZ);
tempChange += change;
tempChange = Math.max(boundaryDown - temperature, tempChange);
tempChange = Math.min(boundaryUp - temperature, tempChange);
tempChange = applyChange(temperature, tempChange, change, boundaryDown, boundaryUp);
}
@Override
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
float humidity = getBiome().rainfall;
humidChange += change;
humidChange = Math.max(boundaryDown - humidity, humidChange);
humidChange = Math.min(boundaryUp - humidity, humidChange);
humidChange = applyChange(humidity, humidChange, change, boundaryDown, boundaryUp);
}
/* GUI */
@@ -19,6 +19,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import forestry.api.core.IClimateControlled;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
import forestry.apiculture.gui.GuiAlvearyHygroregulator;
@@ -31,8 +32,8 @@ import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.tiles.ILiquidTankTile;
public class TileAlvearyHygroregulator extends TileAlveary
implements IInventory, ILiquidTankTile, IFluidHandler, IAlvearyComponent.Climatiser {
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IFluidHandler,
IAlvearyComponent.Climatiser, IMultiblockComponent.HasInventory {
private final HygroregulatorRecipe[] recipes;
@@ -56,9 +57,9 @@ public class TileAlvearyHygroregulator extends TileAlveary
this.tankManager = new TankManager(this, liquidTank);
this.recipes = new HygroregulatorRecipe[] {
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.0005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.0005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.001f) };
new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.01f) };
}
@Override
@@ -111,6 +112,11 @@ public class TileAlvearyHygroregulator extends TileAlveary
}
}
@Override
public int getPriority() {
return 100;
}
/* SAVING & LOADING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -18,6 +18,7 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearySieve;
import forestry.apiculture.gui.GuiAlvearySieve;
@@ -25,7 +26,8 @@ import forestry.apiculture.inventory.InventoryAlvearySieve;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
public class TileAlvearySieve extends TileAlveary implements IAlvearyComponent.BeeListener {
public class TileAlvearySieve extends TileAlveary
implements IAlvearyComponent.BeeListener, IMultiblockComponent.HasInventory {
private final IBeeListener beeListener;
private final InventoryAlvearySieve inventory;
@@ -8,8 +8,9 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
@@ -21,6 +22,7 @@ import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.gui.ContainerAlvearySwarmer;
import forestry.apiculture.gui.GuiAlvearySwarmer;
@@ -36,10 +38,11 @@ import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ItemStackUtil;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
public class TileAlvearySwarmer extends TileAlveary
implements ISidedInventory, IActivatable, IAlvearyComponent.Active, IMultiblockComponent.HasInventory {
private final InventorySwarmer inventory;
private final Stack<ItemStack> pendingSpawns = new Stack<>();
private final Deque<ItemStack> pendingSpawns = new ArrayDeque<>();
private boolean active;
public TileAlvearySwarmer() {
@@ -15,11 +15,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.apiculture.blocks.BlockCandle;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.proxy.Proxies;
@ThreadSafeISBRH(perThread = false)
public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
@Override
@@ -58,7 +61,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
int colour = tileCandle.getColour();
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double d0 = 0.4000000059604645D;
@@ -87,7 +90,7 @@ public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10,
int colour) {
Tessellator tessellator = Tessellator.instance;
final Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
double maxU = icon.getMaxU();
@@ -1,145 +0,0 @@
package forestry.arboriculture;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.world.World;
/** Based on vanilla leaf decay, but accepts leaves that are connected further from a trunk */
public abstract class LeafDecayHelper {
private static final short SUSTAINS_LEAVES = 0;
private static final short NOT_SUSTAINS_LEAVES = -1;
private static final short IS_LEAVES = -2;
private static int[] leafDecayValues;
public static void leafDecay(BlockLeaves leaves, World world, int x, int y, int z) {
if (world.isRemote) {
return;
}
int leafMeta = world.getBlockMetadata(x, y, z);
if ((leafMeta & 8) != 0 && (leafMeta & 4) == 0) {
byte radius = 4;
byte yArrayMult = 32;
int xArrayMult = yArrayMult * yArrayMult;
int arrayOffset = yArrayMult / 2;
if (leafDecayValues == null) {
leafDecayValues = new int[yArrayMult * yArrayMult * yArrayMult];
}
int radius1 = radius + 1;
if (world.checkChunksExist(x - radius1, y - radius1, z - radius1, x + radius1, y + radius1, z + radius1)) {
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
Block block = world.getBlock(x + xOffset, y + yOffset, z + zOffset);
if (!block.canSustainLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
if (block.isLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] = IS_LEAVES;
} else {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] = NOT_SUSTAINS_LEAVES;
}
} else {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] = SUSTAINS_LEAVES;
}
}
}
}
for (int sustainedValue = 1; sustainedValue <= 8; ++sustainedValue) {
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] == sustainedValue - 1) {
if (leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] = sustainedValue;
}
if (leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset] = sustainedValue;
}
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset - 1) * yArrayMult
+ zOffset
+ arrayOffset] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset - 1) * yArrayMult
+ zOffset
+ arrayOffset] = sustainedValue;
}
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset + 1) * yArrayMult
+ zOffset
+ arrayOffset] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset + 1) * yArrayMult
+ zOffset
+ arrayOffset] = sustainedValue;
}
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ (zOffset + arrayOffset - 1)] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ (zOffset + arrayOffset - 1)] = sustainedValue;
}
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset
+ 1] == IS_LEAVES) {
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
+ (yOffset + arrayOffset) * yArrayMult
+ zOffset
+ arrayOffset
+ 1] = sustainedValue;
}
}
}
}
}
}
}
int sustainValue = leafDecayValues[(arrayOffset * xArrayMult) + (arrayOffset * yArrayMult) + arrayOffset];
if (sustainValue >= 0) {
world.setBlockMetadataWithNotify(x, y, z, leafMeta & -9, 4); // stop trying to decay
} else {
leaves.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
}
}
@@ -34,6 +34,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.gtnewhorizon.gtnhlib.blocks.util.BFSLeafDecay;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
@@ -48,7 +49,6 @@ import forestry.api.core.Tabs;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.api.lepidopterology.IButterfly;
import forestry.arboriculture.LeafDecayHelper;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.items.ItemBlockLeaves;
import forestry.arboriculture.render.TextureLeaves;
@@ -230,7 +230,12 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
return;
}
LeafDecayHelper.leafDecay(this, world, x, y, z);
if (!world.isRemote) {
final int meta = world.getBlockMetadata(x, y, z);
if ((meta & 8) != 0 && (meta & 4) == 0) {
BFSLeafDecay.handleDecayChecked(this, world, x, y, z, meta, 4);
}
}
// check leaves tile again because they can decay in super.updateTick
if (tileLeaves.isInvalid()) {
@@ -36,29 +36,29 @@ public class BlockFruitPod extends BlockCocoa {
}
public static TileFruitPod getPodTile(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileFruitPod)) {
return null;
final TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileFruitPod) {
return (TileFruitPod) tile;
}
return (TileFruitPod) tile;
return null;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if (!world.checkChunksExist(x - 1, y, z - 1, x + 1, y, z + 1)) {
return;
}
if (!canBlockStay(world, x, y, z)) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
final int meta = world.getBlockMetadata(x, y, z);
this.dropBlockAsItem(world, x, y, z, meta, 0);
world.setBlockToAir(x, y, z);
return;
}
TileFruitPod tile = getPodTile(world, x, y, z);
if (tile == null) {
return;
final TileFruitPod tile = getPodTile(world, x, y, z);
if (tile != null) {
tile.onBlockTick();
}
tile.onBlockTick();
}
@SuppressWarnings("deprecation")
@@ -16,8 +16,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -72,7 +72,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
return IconProviderWood.getPlankIcon(EnumWoodType.VALUES[meta]);
}
@Override
@@ -84,7 +84,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@Override
protected ItemStack createStackedBlock(int meta) {
return new ItemStack(Blocks.wooden_slab, 2, meta & 7);
Item item = Item.getItemFromBlock(this);
return item != null ? new ItemStack(item, 2, 0) : null;
}
@Override
@@ -107,6 +108,18 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
return new TileWood();
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
// Special case for double slabs placed by building mods (e.g., MatterManipulator)
if (stack == null) return;
int damage = stack.getItemDamage();
if (damage < 0 || damage >= EnumWoodType.VALUES.length) return;
TileWood tile = TileWood.getWoodTile(world, x, y, z);
if (tile != null) {
tile.setWoodType(EnumWoodType.VALUES[damage]);
}
}
/* PROPERTIES */
@Override
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
@@ -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) {
@@ -82,7 +82,7 @@ public enum TreeBranchDefinition implements IBranchDefinition {
@Override
public IAllele[] getTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumTreeChromosome.values().length];
defaultTemplate = new IAllele[EnumTreeChromosome.VALUES.length];
AlleleHelper.instance.set(defaultTemplate, EnumTreeChromosome.FRUITS, AlleleFruit.fruitNone);
AlleleHelper.instance.set(defaultTemplate, EnumTreeChromosome.GROWTH, AlleleGrowth.growthLightLevel);
@@ -1148,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;
@@ -389,7 +389,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
@Override
public IChromosomeType[] getKaryotype() {
return EnumTreeChromosome.values();
return EnumTreeChromosome.VALUES;
}
@Override
@@ -26,6 +26,7 @@ public class ItemRegistryArboriculture extends ItemRegistry {
OreDictionary.registerOre("treeSapling", sapling.getWildcard());
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
OreDictionary.registerOre("itemPollenFertile", pollenFertile.getWildcard());
treealyzer = registerItem(new ItemTreealyzer(), "treealyzer");
grafter = registerItem(new ItemGrafter(4), "grafter");
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
import forestry.arboriculture.gui.GuiTreealyzer;
import forestry.arboriculture.inventory.ItemInventoryTreealyzer;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.inventory.ItemLocation;
import forestry.core.items.ItemWithGui;
public class ItemTreealyzer extends ItemWithGui {
@@ -24,12 +25,12 @@ public class ItemTreealyzer extends ItemWithGui {
}
@Override
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new GuiTreealyzer(player, new ItemInventoryTreealyzer(player, heldItem));
}
@Override
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
return new ContainerAlyzer(new ItemInventoryTreealyzer(player, heldItem), player);
}
}
@@ -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();
@@ -95,8 +95,7 @@ public class TileWood extends TileEntity implements IStreamable {
EnumWoodType woodType = wood.getWoodType();
int amount = 1;
if (block instanceof BlockSlab) {
BlockSlab blockSlab = (BlockSlab) block;
if (block instanceof BlockSlab blockSlab) {
if (blockSlab.isDoubleSlab()) {
amount = 2;
block = PluginArboriculture.blocks.slabs;
@@ -104,6 +103,7 @@ public class TileWood extends TileEntity implements IStreamable {
}
ItemStack itemStack = new ItemStack(block, amount);
if (itemStack.getItem() == null) return null;
ItemBlockWood.saveToItemStack(woodType, itemStack);
return itemStack;
}
@@ -113,11 +113,7 @@ public final class AccessHandler implements IAccessHandler {
if (!isOwner(player)) {
return false;
}
int ordinal = (access.ordinal() + 1) % EnumAccess.values().length;
EnumAccess newAccess = EnumAccess.values()[ordinal];
setAccess(player.worldObj, newAccess);
setAccess(player.worldObj, access.next());
return true;
}
@@ -156,7 +152,7 @@ public final class AccessHandler implements IAccessHandler {
public void readData(DataInputStreamForestry data) throws IOException {
byte accessOrdinal = data.readByte();
if (accessOrdinal >= 0) {
access = EnumAccess.values()[accessOrdinal];
access = EnumAccess.fromOrdinal(accessOrdinal);
GameProfile owner = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF());
setOwner(owner);
}
@@ -164,8 +160,7 @@ public final class AccessHandler implements IAccessHandler {
@Override
public void readFromNBT(NBTTagCompound data) {
access = EnumAccess.values()[data.getInteger("Access")];
access = EnumAccess.fromOrdinal(data.getInteger("Access"));
if (data.hasKey("owner")) {
owner = NBTUtil.func_152459_a(data.getCompoundTag("owner"));
}
@@ -8,22 +8,15 @@
******************************************************************************/
package forestry.core.access;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum EnumAccess {
SHARED("gui.rule.shared"),
VIEWABLE("gui.rule.restricted"),
PRIVATE("gui.rule.private");
private static final EnumAccess[] VALUES = values();
private final String name;
@SideOnly(Side.CLIENT)
private IIcon icon;
EnumAccess(String name) {
this.name = name;
}
@@ -31,4 +24,13 @@ public enum EnumAccess {
public String getName() {
return this.name;
}
public EnumAccess next() {
int ordinal = (this.ordinal() + 1) % VALUES.length;
return VALUES[ordinal];
}
public static EnumAccess fromOrdinal(int ordinal) {
return VALUES[ordinal];
}
}
@@ -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;
@@ -84,31 +84,26 @@ public class BlockSoil extends Block implements IItemTyped {
}
@Override
public void updateTick(World world, int i, int j, int k, Random random) {
public void updateTick(World world, int x, int y, int z, Random random) {
if (world.isRemote) {
return;
}
int meta = world.getBlockMetadata(i, j, k);
int meta = world.getBlockMetadata(x, y, z);
SoilType type = getTypeFromMeta(meta);
if (type == SoilType.HUMUS) {
updateTickHumus(world, i, j, k);
if (world.checkChunksExist(x - 1, y + 1, z - 1, x + 1, y + 1, z + 1)) {
if (isEnrooted(world, x, y, z)) {
degradeSoil(world, x, y, z);
}
}
} else if (type == SoilType.BOG_EARTH) {
updateTickBogEarth(world, i, j, k);
}
}
private static void updateTickHumus(World world, int i, int j, int k) {
if (isEnrooted(world, i, j, k)) {
degradeSoil(world, i, j, k);
}
}
private static void updateTickBogEarth(World world, int i, int j, int k) {
if (isMoistened(world, i, j, k)) {
matureBog(world, i, j, k);
if (world.checkChunksExist(x - 2, y, z - 2, x + 2, y, z + 2)) {
if (isMoistened(world, x, y, z)) {
matureBog(world, x, y, z);
}
}
}
}
@@ -122,7 +117,6 @@ public class BlockSoil extends Block implements IItemTyped {
}
}
}
return false;
}
@@ -156,7 +150,6 @@ public class BlockSoil extends Block implements IItemTyped {
}
private static boolean isMoistened(World world, int x, int y, int z) {
for (int i = -2; i < 3; i++) {
for (int j = -2; j < 3; j++) {
Block block = world.getBlock(x + i, y, z + j);
@@ -165,7 +158,6 @@ public class BlockSoil extends Block implements IItemTyped {
}
}
}
return false;
}
@@ -116,6 +116,12 @@ public abstract class BlockStructure extends BlockForestry {
InventoryUtil.dropSockets((ISocketable) tile, world, x, y, z);
}
}
if (tile instanceof IMultiblockComponent.HasInventory) {
IMultiblockComponent.HasInventory hasInventory = (IMultiblockComponent.HasInventory) tile;
InventoryUtil.dropInventory(hasInventory.getInternalInventory(), world, x, y, z);
}
}
super.breakBlock(world, x, y, z, block, meta);
}
@@ -71,7 +71,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
type = EnumCircuitBoardType.values()[nbttagcompound.getShort("T")];
type = EnumCircuitBoardType.VALUES[nbttagcompound.getShort("T")];
// Layout
if (nbttagcompound.hasKey("LY")) {
@@ -15,6 +15,11 @@ public enum EnumCircuitBoardType {
REFINED((short) 3, 0x191919, 0xc9c9c9),
INTRICATE((short) 4, 0x191919, 0xe2cb6b);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumCircuitBoardType[] VALUES = values();
private final short sockets;
private final int primaryColor;
private final int secondaryColor;
@@ -63,7 +63,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
try {
ICircuitSocketType socketType = layout.getSocketType();
if (CircuitSocketType.FARM.equals(socketType)) {
FarmDirection farmDirection = FarmDirection.values()[i];
FarmDirection farmDirection = FarmDirection.fromOrdinal(i);
String farmDirectionString = farmDirection.toString().toLowerCase(Locale.ENGLISH);
String localizedDirection = StringUtil.localize("gui.solder." + farmDirectionString);
fontRendererObj.drawString(
@@ -50,7 +50,7 @@ public class ItemCircuitBoard extends ItemForestryMultiPass {
@Override
public int getColorFromItemStack(ItemStack itemstack, int pass) {
EnumCircuitBoardType type = EnumCircuitBoardType.values()[itemstack.getItemDamage()];
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[itemstack.getItemDamage()];
if (pass == 0) {
return type.getPrimaryColor();
} else {
@@ -60,7 +60,7 @@ public class ItemCircuitBoard extends ItemForestryMultiPass {
@Override
public String getUnlocalizedName(ItemStack stack) {
EnumCircuitBoardType type = EnumCircuitBoardType.values()[stack.getItemDamage()];
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[stack.getItemDamage()];
return "item.for.circuitboard." + type.toString().toLowerCase(Locale.ENGLISH);
}
@@ -137,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);
@@ -301,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",
@@ -109,6 +109,7 @@ public class Constants implements IForestryConstants {
public static final int MACHINE_MAX_ENERGY = 5000;
public static final int RAINMAKER_RAIN_DURATION_IODINE = 10000;
public static final int RAINMAKER_RAIN_DURATION_PHOSPHORICIODINE = 10000;
public static final int STILL_DESTILLATION_DURATION = 100;
public static final int STILL_DESTILLATION_INPUT = 10;
@@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
@@ -29,6 +28,7 @@ import forestry.core.gui.GuiHandler;
import forestry.core.gui.IGuiHandlerEntity;
import forestry.core.gui.IHintSource;
import forestry.core.tiles.ITitled;
import forestry.core.utils.StringUtil;
public abstract class EntityMinecartForestry extends EntityMinecart
implements ITitled, IRestrictedAccess, IHintSource, IGuiHandlerEntity {
@@ -111,7 +111,7 @@ public abstract class EntityMinecartForestry extends EntityMinecart
@Override
public String getCommandSenderName() {
return StatCollector.translateToLocal(getUnlocalizedTitle());
return StringUtil.localizeGuiTitle(getUnlocalizedTitle());
}
/* ITitled */
@@ -193,7 +193,7 @@ public class BlockForestryFluid extends BlockFluidClassic {
super.updateTick(world, x, y, z, rand);
// Start fires if the fluid is lava-like
if (getMaterial() == Material.lava) {
if (getMaterial() == Material.lava && world.checkChunksExist(x - 4, y, z - 4, x + 4, y, z + 4)) {
int rangeUp = rand.nextInt(3);
for (int i = 0; i < rangeUp; ++i) {
@@ -202,7 +202,8 @@ public abstract class Genome implements IGenome {
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
IChromosome[] chromosomes = new IChromosome[defaultTemplate.length];
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
@@ -213,7 +214,7 @@ public abstract class Genome implements IGenome {
chromosomes[chromosomeOrdinal] = chromosome;
if (Config.clearInvalidChromosomes) {
IAllele template = speciesRoot.getDefaultTemplate()[chromosomeOrdinal];
IAllele template = defaultTemplate[chromosomeOrdinal];
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
.getAlleleClass();
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
@@ -72,6 +72,12 @@ public abstract class ItemGE extends ItemForestry {
if (individual.isAnalyzed()) {
if (Proxies.common.isShiftDown()) {
individual.addTooltip(list);
individual.addDiscoveredBy(list);
if (Proxies.common.isCtrlDown()) {
individual.addLore(list);
} else {
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tml") + ">");
}
} else {
list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">");
}
@@ -8,6 +8,8 @@
******************************************************************************/
package forestry.core.genetics.mutations;
import static forestry.core.utils.MathUtil.safeMultiply;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -126,7 +128,9 @@ public abstract class Mutation implements IMutationCustom {
IGenome genome1, IClimateProvider climate) {
float mutationChance = chance;
for (IMutationCondition mutationCondition : mutationConditions) {
mutationChance *= mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate);
mutationChance = safeMultiply(
mutationChance,
mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate));
if (mutationChance == 0) {
return 0;
}
@@ -172,4 +176,8 @@ public abstract class Mutation implements IMutationCustom {
public boolean isSecret() {
return isSecret;
}
public List<IMutationCondition> getMutationConditions() {
return mutationConditions;
}
}
@@ -32,6 +32,10 @@ public class MutationConditionRequiresResource implements IMutationCondition {
blockRequired = new ItemStack(block, 1, meta);
}
public ItemStack getBlockRequired() {
return blockRequired.copy();
}
@Override
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
IGenome genome1, IClimateProvider climate) {
@@ -39,6 +39,10 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
}
}
public int getOreDictId() {
return oreDictId;
}
@Override
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
IGenome genome1, IClimateProvider climate) {
@@ -36,8 +36,7 @@ public abstract class ContainerForestry extends Container {
// Player inventory
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 9; column++) {
addSlotToContainer(
new Slot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18));
addNormalSlot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18);
}
}
// Player hotbar
@@ -46,6 +45,10 @@ public abstract class ContainerForestry extends Container {
}
}
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
addSlotToContainer(new Slot(playerInventory, slot, x, y));
}
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
addSlotToContainer(new Slot(playerInventory, slot, x, y));
}
@@ -26,6 +26,17 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
addPlayerInventory(playerInventory, xInv, yInv);
}
@Override
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
if (inventory.isParentItemInventory(stackInSlot)) {
addSlotToContainer(new SlotLocked(playerInventory, slot, x, y));
} else {
addSlotToContainer(new Slot(playerInventory, slot, x, y));
}
}
@Override
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
@@ -53,4 +64,13 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
inventory.onSlotClick(player);
return result;
}
@Override
public void detectAndSendChanges() {
if (!inventory.isParentItemEquipped()) {
inventory.getPlayer().closeScreen();
return;
}
super.detectAndSendChanges();
}
}
@@ -25,6 +25,8 @@ import forestry.core.network.packets.PacketAccessUpdate;
import forestry.core.network.packets.PacketErrorUpdate;
import forestry.core.network.packets.PacketGuiEnergy;
import forestry.core.network.packets.PacketGuiUpdate;
import forestry.core.network.packets.PacketTileConfiguration;
import forestry.core.tiles.IConfigurable;
import forestry.core.tiles.IPowerHandler;
import forestry.core.tiles.TilePowered;
import forestry.core.tiles.TileUtil;
@@ -34,6 +36,7 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
protected final T tile;
private final IAccessHandler accessHandler;
private boolean configurationChanged;
protected ContainerTile(T tile) {
this.tile = tile;
@@ -43,6 +46,10 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
} else {
accessHandler = FakeAccessHandler.getInstance();
}
if (tile instanceof IConfigurable) {
configurationChanged = true;
}
}
protected ContainerTile(T tileForestry, InventoryPlayer playerInventory, int xInv, int yInv) {
@@ -128,6 +135,15 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
sendPacketToCrafters(packet);
}
}
if (tile instanceof IConfigurable && configurationChanged) {
configurationChanged = false;
sendPacketToCrafters(new PacketTileConfiguration(tile));
}
}
protected void markConfigurationDirty() {
configurationChanged = true;
}
public void onGuiEnergy(int energyStored) {
@@ -8,10 +8,11 @@
******************************************************************************/
package forestry.core.gui;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Stack;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
@@ -208,7 +209,7 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
textLayout.drawLine(StringUtil.localize("gui.alyzer.classification") + ":", 12);
textLayout.newLine();
Stack<IClassification> hierarchy = new Stack<>();
Deque<IClassification> hierarchy = new ArrayDeque<>();
IClassification classification = individual.getGenome().getPrimary().getBranch();
while (classification != null) {
@@ -10,9 +10,9 @@ package forestry.core.gui;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.StatCollector;
import forestry.core.tiles.ITitled;
import forestry.core.utils.StringUtil;
public abstract class GuiForestryTitled<C extends Container, I extends ITitled & IInventory> extends GuiForestry<C, I> {
@@ -24,7 +24,7 @@ public abstract class GuiForestryTitled<C extends Container, I extends ITitled &
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
String name = StatCollector.translateToLocal(inventory.getUnlocalizedTitle());
String name = StringUtil.localizeGuiTitle(inventory.getUnlocalizedTitle());
textLayout.line = 6;
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
bindTexture(textureFile);
+82 -40
View File
@@ -8,6 +8,10 @@
******************************************************************************/
package forestry.core.gui;
import static forestry.core.inventory.ItemLocation.Type.PLAYER_INVENTORY;
import javax.annotation.Nullable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -18,6 +22,7 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.api.core.ForestryAPI;
import forestry.core.inventory.ItemLocation;
public class GuiHandler implements IGuiHandler {
@@ -39,6 +44,20 @@ public class GuiHandler implements IGuiHandler {
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, 0, 0, 0);
}
/**
* Opens gui for item placed in player's inventory.
*
* @param entityPlayer Player.
* @param guiHandler GUI handler for item.
* @param data Data for item.
* @param invSlotIdx Index or slot in player inventory should be in range [0, 40).
*/
public static void openGui(EntityPlayer entityPlayer, IGuiHandlerItem guiHandler, short data, int invSlotIdx) {
assert invSlotIdx >= 0 && invSlotIdx < 40 : "Incorrect inventory index is used: " + invSlotIdx;
int guiData = encodeGuiData(guiHandler, data, invSlotIdx);
entityPlayer.openGui(ForestryAPI.instance, guiData, entityPlayer.worldObj, 0, 0, 0);
}
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler) {
openGui(entityplayer, guiHandler, (short) 0);
}
@@ -56,8 +75,32 @@ public class GuiHandler implements IGuiHandler {
}
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data) {
return encodeGuiData(guiHandler, data, -1);
}
/**
* Encodes data required for GUI handler to function properly. Because of minecraft implementation we are limited to
* 32 bits.
*
* @param guiHandler GUI handler.
* @param data High bits which were encoded by GUI handler.
* @param invSlotIdx Slot index in the player's inventory should be in range [0,40).
* @return Encoded data.
*/
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data, int invSlotIdx) {
// inventory slot idx will be encoded in third byte
// player inventory has 40 slots which means that we need 6 bits to encode all values.
// first 2 bits are reserved for type currently values 0(heldItem) and 1(item inventory) have meaning,
// 2 and 3 are reserved for possible extension.
if (invSlotIdx < -1 || invSlotIdx >= 40) {
throw new IllegalArgumentException("Inventory slot index should be in range [-1, 40)");
}
int invData = invSlotIdx == -1 ? 0 : (0x40 | invSlotIdx);
GuiId guiId = GuiIdRegistry.getGuiIdForGuiHandler(guiHandler);
return data << 16 | guiId.getId();
return data << 16 | invData << 8 | guiId.getId();
}
private static GuiId decodeGuiID(int guiData) {
@@ -69,8 +112,24 @@ public class GuiHandler implements IGuiHandler {
return (short) (guiId >> 16);
}
private static int decodeInvSlotIdx(int guiData) {
boolean invEncoded = (0x00_00_40_00 & guiData) != 0;
return invEncoded ? (guiData & 0x00_00_3F_00) >> 8 : -1;
}
@Override
public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
return getGuiElement(false, guiData, player, world, x, y, z);
}
@Override
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
return getGuiElement(true, guiData, player, world, x, y, z);
}
private @Nullable Object getGuiElement(boolean isServerSide, int guiData, EntityPlayer player, World world, int x,
int y, int z) {
GuiId guiId = decodeGuiID(guiData);
if (guiId == null) {
return null;
@@ -79,11 +138,25 @@ public class GuiHandler implements IGuiHandler {
switch (guiId.getGuiType()) {
case Item: {
ItemStack heldItem = player.getCurrentEquippedItem();
int slotIdx = decodeInvSlotIdx(guiData);
ItemStack heldItem;
ItemLocation loc;
if (slotIdx == -1) {
heldItem = player.getCurrentEquippedItem();
loc = ItemLocation.HELD_BY_PLAYER;
} else {
heldItem = player.inventory.getStackInSlot(slotIdx);
loc = new ItemLocation(PLAYER_INVENTORY, slotIdx);
}
if (heldItem != null) {
Item item = heldItem.getItem();
if (guiId.getGuiHandlerClass().isInstance(item)) {
return ((IGuiHandlerItem) item).getGui(player, heldItem, data);
if (isServerSide) {
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data, loc);
}
return ((IGuiHandlerItem) item).getGui(player, heldItem, data, loc);
}
}
break;
@@ -91,6 +164,9 @@ public class GuiHandler implements IGuiHandler {
case Tile: {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
if (isServerSide) {
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
}
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
}
break;
@@ -98,6 +174,9 @@ public class GuiHandler implements IGuiHandler {
case Entity: {
Entity entity = world.getEntityByID(x);
if (guiId.getGuiHandlerClass().isInstance(entity)) {
if (isServerSide) {
return ((IGuiHandlerEntity) entity).getContainer(player, data);
}
return ((IGuiHandlerEntity) entity).getGui(player, data);
}
break;
@@ -105,41 +184,4 @@ public class GuiHandler implements IGuiHandler {
}
return null;
}
@Override
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
GuiId guiId = decodeGuiID(guiData);
if (guiId == null) {
return null;
}
short data = decodeGuiData(guiData);
switch (guiId.getGuiType()) {
case Item: {
ItemStack heldItem = player.getCurrentEquippedItem();
if (heldItem != null) {
Item item = heldItem.getItem();
if (guiId.getGuiHandlerClass().isInstance(item)) {
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data);
}
}
break;
}
case Tile: {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
}
break;
}
case Entity: {
Entity entity = world.getEntityByID(x);
if (guiId.getGuiHandlerClass().isInstance(entity)) {
return ((IGuiHandlerEntity) entity).getContainer(player, data);
}
break;
}
}
return null;
}
}
@@ -119,6 +119,13 @@ public class GuiIdRegistry {
classMap.put(tileGuiHandlerClass, guiId);
idMap.put(guiId.getId(), guiId);
}
if (idMap.size() > 256) {
// see {@link GuiHandler.encodeGuiData(forestry.core.gui.IGuiHandlerForestry, short, int)}
throw new IllegalStateException(
"Current implementation can't have more than different 256 GUI handlers "
+ "because its id is coded by 8 bits");
}
}
public static GuiId getGuiIdForGuiHandler(IGuiHandlerForestry guiHandler) {
@@ -11,9 +11,11 @@ package forestry.core.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.core.inventory.ItemLocation;
public interface IGuiHandlerItem extends IGuiHandlerForestry {
Object getGui(EntityPlayer player, ItemStack heldItem, int data);
Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
Object getContainer(EntityPlayer player, ItemStack heldItem, int data);
Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
}
@@ -138,6 +138,10 @@ public abstract class Ledger {
return false;
}
public boolean acceptMouseButton(int mouseButton) {
return mouseButton == 0;
}
public boolean intersectsWith(int mouseX, int mouseY) {
return mouseX >= currentShiftX && mouseX <= currentShiftX + currentWidth
&& mouseY >= currentShiftY
@@ -159,29 +159,28 @@ public class LedgerManager {
}
public void handleMouseClicked(int x, int y, int mouseButton) {
Ledger ledger = this.getAtPosition(x, y);
if (ledger == null || !ledger.acceptMouseButton(mouseButton)) {
return;
}
if (mouseButton == 0) {
// Default action only if the mouse click was not handled by the
// ledger itself.
if (!ledger.handleMouseClicked(x, y, mouseButton)) {
Ledger ledger = this.getAtPosition(x, y);
// Default action only if the mouse click was not handled by the
// ledger itself.
if (ledger != null && !ledger.handleMouseClicked(x, y, mouseButton)) {
List<? extends Ledger> toggleLedgers;
if (ledgers.contains(ledger)) {
toggleLedgers = ledgers;
} else {
toggleLedgers = errorLedgers;
}
for (Ledger other : toggleLedgers) {
if (other != ledger && other.isOpen()) {
other.toggleOpen();
}
}
ledger.toggleOpen();
List<? extends Ledger> toggleLedgers;
if (ledgers.contains(ledger)) {
toggleLedgers = ledgers;
} else {
toggleLedgers = errorLedgers;
}
for (Ledger other : toggleLedgers) {
if (other != ledger && other.isOpen()) {
other.toggleOpen();
}
}
ledger.toggleOpen();
}
}
@@ -0,0 +1,78 @@
package forestry.core.gui.ledgers;
import java.util.Locale;
import net.minecraft.util.IIcon;
import forestry.core.render.TextureManager;
import forestry.core.tiles.IIngredientsSearchController;
import forestry.core.tiles.IngredientsStorage;
import forestry.core.utils.StringUtil;
public class SearchIngregientsLedger extends Ledger {
private final IIngredientsSearchController ingredientsSearch;
public SearchIngregientsLedger(LedgerManager manager, IIngredientsSearchController ingredientsSearch) {
super(manager, "search_ingredients");
this.ingredientsSearch = ingredientsSearch;
this.maxHeight = 36;
}
private boolean isSwitchButton(int mouseX, int mouseY) {
int shiftX = currentShiftX + 20;
int shiftY = currentShiftY + 8;
return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 24;
}
@Override
public void draw(int x, int y) {
// Draw background
drawBackground(x, y);
// Draw icon
IIcon icon = TextureManager.getInstance().getDefault(
"misc/search_ingredients."
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
drawIcon(icon, x + 3, y + 4);
// Draw description
if (!isFullyOpened()) {
return;
}
drawHeader(StringUtil.localize("gui.search_ingredients"), x + 22, y + 8);
drawText(
StringUtil.localize(
"gui.search_ingredients."
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH)),
x + 22,
y + 20);
}
@Override
public String getTooltip() {
return StringUtil.localize("gui.search_ingredients") + ": "
+ StringUtil.localize(
"gui.search_ingredients."
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
}
@Override
public boolean handleMouseClicked(int x, int y, int mouseButton) {
if (isSwitchButton(x, y)) {
IngredientsStorage ingredientsStorage = ingredientsSearch.getIngredientsStorage();
IngredientsStorage newIngredientsStorage = mouseButton == 0 ? ingredientsStorage.next()
: ingredientsStorage.previous();
ingredientsSearch.setIngredientsStorage(newIngredientsStorage);
return true;
}
return false;
}
@Override
public boolean acceptMouseButton(int mouseButton) {
return mouseButton == 0 || mouseButton == 1;
}
}
@@ -20,12 +20,14 @@ public class SlotCrafter extends SlotCrafting {
private final IInventory craftMatrix;
private final ICrafterWorktable crafter;
private final EntityPlayer player;
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafterWorktable crafter, int slot, int xPos,
int yPos) {
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
this.craftMatrix = craftMatrix;
this.crafter = crafter;
this.player = player;
}
@Override
@@ -39,7 +41,7 @@ public class SlotCrafter extends SlotCrafting {
@Override
public boolean canTakeStack(EntityPlayer player) {
return crafter.canTakeStack(getSlotIndex());
return crafter.canTakeStack(player, getSlotIndex());
}
@Override
@@ -49,7 +51,7 @@ public class SlotCrafter extends SlotCrafting {
@Override
public boolean getHasStack() {
return getStack() != null && crafter.canTakeStack(getSlotIndex());
return getStack() != null && crafter.canTakeStack(player, getSlotIndex());
}
@Override
@@ -28,11 +28,17 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
private final EntityPlayer player;
private final ItemStack parent;
private final ItemStack[] inventoryStacks;
private final ItemLocation location;
public ItemInventory(EntityPlayer player, int size, ItemStack parent) {
this(player, size, parent, ItemLocation.UNKNOWN);
}
public ItemInventory(EntityPlayer player, int size, ItemStack parent, ItemLocation loc) {
this.player = player;
this.parent = parent;
this.inventoryStacks = new ItemStack[size];
this.location = loc;
setUID(); // Set a uid to identify the itemstack on SMP
@@ -78,13 +84,32 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
}
}
public boolean isParentItemEquipped() {
return switch (location.type()) {
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent);
};
}
public EntityPlayer getPlayer() {
return player;
}
public ItemLocation getLocation() {
return location;
}
public boolean isParentItemInventory(ItemStack itemStack) {
ItemStack parent = getParent();
return isSameItemInventory(parent, itemStack);
}
protected ItemStack getParent() {
ItemStack equipped = player.getCurrentEquippedItem();
ItemStack equipped = switch (location.type()) {
case HELD_BY_PLAYER, UNKNOWN -> player.getCurrentEquippedItem();
case PLAYER_INVENTORY -> player.inventory.getStackInSlot(location.slotIdx());
};
if (isSameItemInventory(equipped, parent)) {
return equipped;
}
@@ -121,11 +121,11 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
}
// Illegal type
if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.values().length) {
if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.VALUES.length) {
return;
}
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()];
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[blank.getItemDamage()];
if (getCircuitCount() != type.getSockets()) {
return;
}
@@ -172,7 +172,7 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
if (blankCircuitBoard == null) {
errorStates.add(EnumErrorCode.NO_CIRCUIT_BOARD);
} else {
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blankCircuitBoard.getItemDamage()];
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[blankCircuitBoard.getItemDamage()];
int circuitCount = 0;
for (short i = 0; i < type.getSockets(); i++) {
@@ -0,0 +1,32 @@
package forestry.core.inventory;
/**
* Location of items in inventory.
*/
public class ItemLocation {
public enum Type {
UNKNOWN,
HELD_BY_PLAYER,
PLAYER_INVENTORY
}
public static final ItemLocation UNKNOWN = new ItemLocation(Type.UNKNOWN, -1);
public static final ItemLocation HELD_BY_PLAYER = new ItemLocation(Type.HELD_BY_PLAYER, -1);
private final Type type;
private final int slotIdx;
public ItemLocation(Type type, int slotIdx) {
this.type = type;
this.slotIdx = slotIdx;
}
public Type type() {
return type;
}
public int slotIdx() {
return slotIdx;
}
}
Loaded 100 of 403 files, more files were not shown because too many files have changed in this diff. Show more