Compare commits

..
137 Commits
Author SHA1 Message Date
Martin Robertz 13bf6d3be8 update 2026-03-11 16:00:34 +01:00
Martin Robertz 77803f4c3f Merge remote-tracking branch 'brandyyn/master' into dev 2026-03-11 15:58:12 +01:00
Martin Robertz ed6060280a Merge remote-tracking branch 'origin/splicer_fix' into dev 2026-03-11 15:56:37 +01:00
UltraProdigy 63232799bc Optimize Images & Workflow (#88) 2026-03-08 09:28:38 +01:00
Alexdoru a48f59e0ed Cache frequent Enum#values() calls (#86) 2026-03-04 16:15:04 +01:00
Martin Robertz 36a4b43837 Merge branch 'master' into master 2026-02-28 21:46:56 +01:00
Martin Robertz c29ac8f8ff Merge branch 'master' into splicer_fix 2026-02-28 21:46:48 +01:00
Guillaume MercierandCaedis 84d462d8d5 CropsNH Integration/IC2 Depreciation (#82)
Co-authored-by: Caedis <[email protected]>
2026-02-28 20:55:58 +01:00
Casey Primozic b32f2a210c Fix incorrect integer division in getRipeningStage (#85) 2026-02-18 02:20:41 -06:00
Caedis 1ea465c688 Merge branch 'master' into master 2026-02-09 05:38:34 -06:00
Caedis c988aa9870 Cache inventory size in compartments (#84) 2026-02-09 14:29:52 +03:00
brandyn 6c24da5270 Fix ceramic tiles + Add config option to disable compartments
Fix missing pixels in ceramic tiles

Fix rendering of ceramic tiles

Fix crashes of rendering ceramic tiles and breaking ceramic tiles

Add config option to disable compartments
2026-02-02 17:07:48 +00:00
Martin Robertz a52f1b0926 Merge branch 'master' into splicer_fix 2026-01-30 10:51:47 +01:00
ah-OOG-ah 6ba66123eb Yeet reflective item parsing (#75) 2026-01-27 22:29:12 -05:00
Ranzu 1d0568388a Added title localization and inventory slot texture (#81) 2026-01-07 18:37:36 +01:00
TweksTY 3968cc320e Fix the inability to mutate a bee that requires a certain block as a base using alveary if the bottom center block of your alveary is any alveary block from Extra Bees (#80) 2026-01-07 12:29:12 +01:00
DarkShadow44 ed1daa1e96 Mark sequence as not repairable (#79) 2025-12-13 20:58:30 +01:00
Fabian Maurer 2e159f1983 Merge remote-tracking branch 'origin/master' into splicer_fix 2025-12-12 21:01:02 +01:00
Alexdoru ffcc5f7102 [Memory-opti:runtime allocations] Reduce amount of NBTTagCompound created in TileEntityMetadata#getItemStack (#77) 2025-12-01 23:35:01 +01:00
Fabian Maurer dde6c79f9e Move out larvae from splicer even when no serum is present anymore 2025-11-12 23:13:18 +01:00
Martin Robertz 4c619fd3b2 update 2025-10-01 18:48:17 +02:00
Glease 341fea50ba fix batched updates does not call window and machine packet listeners (#74) 2025-09-28 10:52:47 +02:00
Julia e6c67df077 Fix Slot Registration Crash (#73) 2025-09-25 15:46:12 +02:00
d24088ea4b Fix metadata error when using Scooporator MX200 Turbo (#69)
Co-authored-by: Wilhelm Schuster <[email protected]>
Co-authored-by: boubou19 <[email protected]>
2025-09-24 23:44:33 +02:00
Julia a2a57d1656 Batch Actions and Defer Registration of Slots (#72) 2025-09-24 23:25:39 +02:00
Julia 2e36fbcfcc Extract Magic String Constants in ContainerCraftGUI (#70) 2025-09-24 17:46:47 +02:00
Martin Robertz bd5bd5c153 update 2025-09-24 17:37:45 +02:00
Julia f324cb53db Fix Inventory List Crash (#71) 2025-09-24 17:29:33 +02:00
Julia c6815bebdf Cleanup ContainerCraftGUI (#68) 2025-09-23 17:46:40 -07:00
Julia 7ffa516892 Change recieve -> receive (#67) 2025-09-23 14:26:33 -07:00
Julia 311d618d53 Cleanup BinnieCorePacketID.java (#66) 2025-09-23 12:54:21 -07:00
Dream Master 9795aad66f update 2025-09-05 16:05:56 +02:00
Matthew Bentham ea7e2d7de4 Fix mutator not accepting items listed on the wiki (#65) 2025-09-05 09:44:41 +02:00
boubou19andAlexdoru 39f86c8b0c Speed up forge event registration (#64)
Co-authored-by: Alexdoru <[email protected]>
2025-07-18 22:22:10 +00:00
TotallyNotOndre 5b551eb8ec "fix" compartment tab name input field (#63) 2025-07-15 19:39:33 +02:00
Martin Robertz f497114579 update 2025-07-08 12:11:02 +02:00
Alexdoru ea547df4d0 Properly apply hunger effect (#62) 2025-07-07 21:42:49 +02:00
Ruling-0 39c9f1f6c6 Remove mutator mutation chance cap (#61) 2025-05-25 17:30:06 +02:00
Maya 4000763323 update 2025-05-07 10:39:29 -05:00
czerwonogrodzki 59e98dd290 Extend Lab Stand GUI width by 80 units (#60) 2025-05-07 10:38:14 -05:00
Maya c1ec3e5c8e Fix stained block hardness (#59) 2025-04-09 01:22:18 -05:00
Maya ac4b21b05e update 2025-04-08 14:24:47 -05:00
Niclas Klugmann 0e0ded5cc0 Revert 5x multiplier removal (#58) 2025-04-08 14:23:05 -05:00
Martin Robertz a1f54e7500 update 2025-01-16 21:59:06 +01:00
Astatine5985andMaya 5f1b5daa24 Isolator crash fix revision (#56)
Co-authored-by: Maya <[email protected]>
2025-01-16 16:50:35 +00:00
Martin Robertz 8d0fa2ebb5 update 2024-12-30 21:12:54 +01:00
glowredman 0db05cb60c Add Localization, Fix Carpentry Hammer / Master Carpentry Hammer Names being reverse (#57) 2024-12-30 21:11:13 +01:00
0265d70a53 Yeet custom config in favor of NHLib (#53)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2024-12-29 12:37:43 -06:00
Martin Robertz 32b7efcd15 update 2024-12-22 01:17:03 +01:00
Guillaume Mercier 7059206cb0 prevent npe and log bad requests (#55) 2024-12-21 10:35:14 -06:00
Martin Robertz 54c702e935 update 2024-11-13 07:12:13 +01:00
Ryan Nasers a3aa358627 Fixing Waila showing incorrect blocks for logs (#54) 2024-11-12 22:04:26 +01:00
ah-OOG-ah f0f14bb278 Minor cleanups (#50)
* Finalize, minor alloc reduction

Also enable Jabel and generic injection

* Update dependencies.gradle

* Clean up Machine a bit

* spotless

more enhanced instanceof

* Update ModuleMachine.java

* More clen

* WARN: Removed exception catching

* Many, many tiny patches + birthday fix

* Spotless

* Spotless again

* Fix getLow and clamp tolerance value

* Revert event -> ignored on unused event parameters

* Rename instanceof variables

* Update Machine.java

* Use StringBuilder

* Cache getStack()

* Oops, Jabel can't handle that

* Spotless

* Spotless again

My IDE was fighting with it

* Remove unused elements + scream test success
2024-09-26 16:59:20 +02:00
Martin Robertz 6b4f3eb1c7 update 2024-09-15 14:30:24 +02:00
Ryan Nasers f74f9e4967 Should be fixed (#49) 2024-09-15 11:07:23 +02:00
Dream Master 12643d1b98 update 2024-08-09 20:41:23 +07:00
Ethryan 5bf4224f03 don't let players eat fluids anymore (#48) 2024-08-09 19:54:49 +07:00
Martin Robertz 5a1030bde4 update 2024-05-31 19:00:50 +02:00
Martin Robertz 948876ffcd Dev (#47)
* Update settings.gradle

* Update gradle-wrapper.properties

* Update dependencies.gradle
2024-05-31 11:23:46 +02:00
chochem 83142abde9 fix division by zero (#46) 2024-05-31 10:38:45 +02:00
Martin Robertz 79cda2e4fd update 2024-03-29 23:42:27 +01:00
DrParadox7 5409309b36 Flower Butterfly Spawns inherits Forestry's configs constraints (#45) 2024-03-29 23:41:24 +01:00
Martin Robertz 1a6e6b3c2c update 2024-02-18 10:54:02 +01:00
Jason Mitchell e5dfcc7942 No more restriction by player name (#44)
* Remove the ability to lock a bee to a specific person, and instead give them acknowledgement.

* Restrict to feb 29th - effectively not allowed unless you're a real chad :trollface: and still gives mentions to the people
2024-02-17 16:27:57 -08:00
Raven Szewczyk ea78ca8069 [ci skip] upgraded build system 2024-02-04 19:57:04 +00:00
Martin Robertz 29814550bb update deps+bs 2024-01-25 10:42:36 +01:00
ghostflyby 15769b9ee9 fix no tooltip in some Gui (#42) 2024-01-24 21:44:37 +01:00
Martin Robertz 1253271111 update bs+deps 2024-01-11 22:55:32 +01:00
Raven Szewczyk d18be7848d [ci skip] upgraded build system 2024-01-08 21:24:08 +00:00
Martin Robertz ef4dd3710a update gradle+bs+deps 2023-12-11 11:41:14 +01:00
ghostflyby 190693ad68 Fix double layers tooltip with NEI (#41)
* Fix double layers tooltip with nei

* Remove wildcard imports
2023-12-11 08:43:58 +01:00
Martin Robertz 3dc2806b36 update bs+deps 2023-11-15 10:13:07 +01:00
Pelotrio a609f5dce5 Optimized flower color enumeration array retrieval (#40) 2023-11-15 00:19:42 +00:00
Martin Robertz 00c214ee5d update deps 2023-10-21 12:22:30 +02:00
miozune e497b9505a Optimize PlankType$ExtraBiomesPlank.getStack() (#39) 2023-10-21 10:55:44 +02:00
Martin Robertz b5ac446e55 update bs+deps 2023-10-11 23:14:28 +02:00
ghostflyby c00e1b39da NEI item manager overlay integration (#38)
* New: NEI item manager overly integration

* update buildscript

* apply spotless

* Making nei really optional

* Fix wildcard

* Stream chain simplify

* Fix: NPE when events outside the Gui

* Fix: drag and mouse event

* Fix: call mouse event
2023-10-11 14:35:28 +09:00
Lyfts 6e6e806476 fix incubator for real this time (#37) 2023-09-06 19:48:53 +02:00
miozuneandMartin Robertz ef877e2f7d Fix NPE with Lumbermill (#35)
* Remove outdated script

* updateBuildScript

* Update dependencies

* Fix NPE with Lumbermill

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-08-19 12:34:10 +02:00
miozune 669aee5ba6 Fix typo: cooper -> copper (#34) 2023-08-12 15:31:22 +02:00
Martin Robertz ef468097d0 update bs+deps 2023-07-18 20:37:11 +02:00
hacatu 22f2eebbd3 Fix Additive Production (#33)
* Fix production modifiers to be additive, fix circuit tooltips for mutation and boolean modifiers

* Chocolate frames have left the building

kuba told me to kill them

* Bruhhhhhhhhhhhh
2023-07-18 20:36:09 +02:00
Maxim f658e9ec57 Fixed the stimulator accepting stacks with a size higher than 1 (#32) 2023-06-16 16:24:18 +02:00
Maxim ddf93bc425 Fix localization of secret species count (#31) 2023-06-14 19:03:59 +02:00
Maxim 503361d6d1 Added alveary unlighting (#30) 2023-06-08 12:39:11 +02:00
DrParadox7 77edab1ba7 Fix SwampGum (#29)
Reverts swampgum stats to that of 1.6.4
2023-05-30 14:26:21 +00:00
Runakai1andMartin Robertz 7760c556a7 Add OrderedSky to Chadbee whitelist (#28)
* Add OrderedSky to Chadbee whitelist

* update bs+sa

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-05-21 19:04:00 +00:00
Dane Strandboge 5a9c7fb027 Fix frame overrides not respecting maxDamage field (#27) 2023-04-28 19:01:17 +02:00
Raven Szewczyk 1f3bcbc746 [ci skip] upgraded build system 2023-01-31 09:51:21 +00:00
Jason Mitchell d0cdc58b5a [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-28 19:14:12 -08:00
Jason Mitchell 91bf137a94 [ci skip] spotlessApply with the new settings 2023-01-28 19:14:12 -08:00
Jason Mitchell 07f445757b [ci skip] Update buildscript to RetroFuturaGradle 2023-01-28 19:13:42 -08:00
Raven Szewczyk f2f1dd1195 Make reflection Java 12+ compatible, mark mods as children of the main mod (#26)
* Update buildscript and dependencies

* Update NEI api

* Make reflection Java 12+ compatible, mark mods as children of the main mod
2023-01-25 20:47:58 +01:00
Runakai1 c70a3448e5 Revert some mistakes (#25) 2022-12-05 08:59:59 -08:00
Martin Robertz 65c6f2b591 Merge pull request #24 from GTNewHorizons/BlackmailedChadChange
Blackmailed chad change
2022-12-05 17:47:21 +01:00
Runakai1 350c7ed1af I think I fixed it? 2022-12-05 17:43:17 +01:00
Runakai1 8b07f1ff4f Blaickmailed to remove the blackmailed grouping 2022-12-05 17:09:42 +01:00
Runakai1 09b631faee Add my beloved Alright 2022-12-05 16:59:12 +01:00
Runakai1 d1d09c3bfb Grouping them blackmailers together 2022-12-05 16:52:58 +01:00
Runakai1 1189f1ccb2 Add Colen and Tyrant to chad bee 2022-12-05 16:48:34 +01:00
Martin Robertz bf12c01b96 Merge pull request #23 from GTNewHorizons/toolong
Add new lines to multiple people requirement bees.
2022-10-09 15:02:36 +02:00
kuba6000 f28ae4b8e4 Update buildscript 2022-10-09 14:54:38 +02:00
kuba6000 d9f5acd98a Make it pretty 2022-10-09 14:52:07 +02:00
Martin Robertz 4f3c73ee98 Merge pull request #22 from Runakai1/ChaddyMergeBee
Add All Mighty Merge Master
2022-10-09 12:58:08 +02:00
Runakai1 a14ed03d5e Merge branch 'master' into ChaddyMergeBee 2022-10-09 12:57:00 +02:00
Runakai1 a80a7429b1 Add All Mighty Merge Master 2022-10-09 12:56:18 +02:00
Runakai1 8541ba8e53 Merge pull request #21 from Runakai1/ChaddyBaddyBeebee
Add kuba6000 to chad bee
2022-10-09 12:48:20 +02:00
Runakai1 3d65061055 Add kuba6000 to chad bee 2022-10-09 12:41:09 +02:00
Martin Robertz 41d1e97d7c Merge pull request #20 from Kiwi233/master-MC1.7.10
Update zh_CN.lang
2022-09-24 12:41:12 +02:00
[Kiwi233] a811e2b5e4 Update zh_CN.lang 2022-09-24 11:18:30 +08:00
Martin Robertz 4ba17bf8f3 Merge pull request #19 from Runakai1/ChadBeeLang
Updated lang file for chad bee so it finally works
2022-08-15 15:18:54 +02:00
Runakai1 0ae7dcefa3 Updated lang file for chad bee so it finally works 2022-08-15 14:50:12 +02:00
Connor-Colenso bc95495504 Merge pull request #18 from AlbertoPirillo/genetics-better-info
Genetics - Better info for Acclimatiser and Isolator
2022-08-12 22:23:46 +01:00
Alberto Pirillo 004c540346 Update Genetics Isolator's info to state that it has a chance to destroy the individual 2022-08-12 16:56:48 +02:00
Alberto Pirillo c43f1f05c5 Update Genetics Acclimatizer's info to state that it only has a chance to succeed 2022-08-11 01:42:37 +02:00
Martin Robertz 3ce7424abc Merge pull request #17 from Runakai1/bees-balance-change
Changed Format
2022-07-31 16:47:36 +07:00
Runakai1 5cafd12ce8 Changed Format
Changed Format of Names for the Chad Bee
2022-07-31 11:10:11 +02:00
Martin Robertz 9a423c4bfd Merge pull request #16 from Runakai1/bees-balance-change
bees-balance-changes in ExtraBees
2022-07-31 14:17:55 +07:00
Runakai1 e4d248b5a9 Changed Mutatron and Flowers
Added a new Bedrock Flower
Modified Mutatron Numbers based on Wiki. Also buffed some.
Uranfuel: 4->8
MOXFuel removed
Plutonium: 8->15
smallPlutonium: 5->9
Uran235: 4->10
smallUran: 2.5 -> 5.5
Nether star: 50
2022-07-30 23:15:46 +02:00
Runakai1 4520180638 added Jimbo
(he made the multiblock design) VERY BEAUTIFUL
2022-07-29 18:25:15 +02:00
Runakai1 7d14960a72 Mitch.
Mitch.
2022-07-29 18:19:15 +02:00
Runakai1 66bb31bfa8 Added one Bee
Added the Chad bee
Added RestrictedByGroup breeding requirement
2022-07-29 17:42:00 +02:00
Jason Mitchell 37bb054dd3 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:46:59 -07:00
Connor-Colenso 0c9ed04ac5 Merge pull request #15 from DianeXD/fix-genedatabase
Allow gene database to add species with the same name
2022-07-11 05:14:54 +01:00
DianeXD c641da2f7f Allow gene database to add species with the same name 2022-07-06 14:57:24 +08:00
Martin Robertz c91da9fee9 Merge pull request #13 from DianeXD/master
NEI Integration
2022-07-03 14:58:56 +07:00
DianeXD 4d67be487a Resolve conflict... 2022-07-03 12:40:52 +08:00
DianeXD 60325eeab9 Resolve conflict 2022-07-03 12:32:57 +08:00
DianeXD 8683a345c3 Update buildscript & spotlessApply 2022-07-03 12:17:51 +08:00
DianeXD e4329e2b8f Merge branch 'GTNewHorizons:master' into master 2022-07-03 12:07:41 +08:00
Connor-Colenso 2e193f2b8f Merge pull request #14 from DianeXD/Fix-worker 2022-07-03 04:38:04 +01:00
DianeXD bc4ec455e5 Fix ExtraTrees worker 2022-07-03 10:34:56 +08:00
DianeXD ba9e3ccf3e Fix tip 2022-06-30 16:38:14 +08:00
DianeXD ea417583b6 Change handler name 2022-06-29 22:52:11 +08:00
DianeXD 4ffe81967d Add NEI support for ExtraTrees 2022-06-29 22:48:09 +08:00
DianeXD 4aaa092db9 Add NEI support for Genetics 2022-06-29 20:45:17 +08:00
DianeXD 2f796f4478 Update buildscript 2022-06-29 20:28:41 +08:00
2708 changed files with 56546 additions and 52309 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
91bf137a94d1207f943929e0881750a1b8c4f3bf
+44
View File
@@ -0,0 +1,44 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env bash
RUNDIR="run"
CRASH="crash-reports"
SERVERLOG="server.log"
if [[ -d $RUNDIR/$CRASH ]]; then
echo "Crash reports detected:"
cat $RUNDIR/$CRASH/crash*.txt
exit 1
fi
if grep --quiet "Fatal errors were detected" $SERVERLOG; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" $SERVERLOG; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' $SERVERLOG; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+2 -34
View File
@@ -1,5 +1,3 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
@@ -11,35 +9,5 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1.5 minutes
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
- name: Test no errors reported during server run
run: |
chmod +x .github/scripts/test-no-error-reports.sh
.github/scripts/test-no-error-reports.sh
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+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
+7 -44
View File
@@ -1,51 +1,14 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build
on:
push:
tags:
- '*'
tags: [ '*' ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
- name: Publish to Maven
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+7 -1
View File
@@ -26,7 +26,13 @@ whitelist.json
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
+2 -728
View File
@@ -1,731 +1,5 @@
//version: 1644612407
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput.Style
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.concurrent.TimeUnit
buildscript {
repositories {
maven {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
maven {
name 'jitpack'
url 'https://jitpack.io'
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
}
}
//version: 1707058017
plugins {
id 'java-library'
id 'idea'
id 'eclipse'
id 'scala'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
}
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
def out = services.get(StyledTextOutputFactory).create('an-output')
apply plugin: 'forge'
def projectJavaVersion = JavaLanguageVersion.of(8)
java {
toolchain {
languageVersion.set(projectJavaVersion)
}
}
idea {
module {
inheritOutputDirs = true
downloadJavadoc = true
downloadSources = true
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinPlugin")
checkPropertyExists("mixinsPackage")
checkPropertyExists("coreModClass")
checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
if(accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
// Make sure GregTech build won't time out
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
}
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
try {
'git config core.fileMode false'.execute()
}
catch (Exception e) {
out.style(Style.Failure).println("git isn't installed at all")
}
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception e) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
version = minecraftVersion + '-' + identifiedVersion
ext {
modVersion = identifiedVersion
}
if( identifiedVersion.equals(versionOverride) ) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
}
else {
archivesBaseName = modId
}
def arguments = []
def jvmArguments = []
if(usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
jvmArguments += [
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
]
}
minecraft {
version = minecraftVersion + '-' + forgeVersion + '-' + minecraftVersion
runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
replace gradleTokenVersion, modVersion
}
if(gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
clientIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
if(developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}
serverIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
}
}
if(file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}
repositories {
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
if(usesMixins.toBoolean()) {
maven {
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
}
maven {
url 'https://jitpack.io'
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
}
}
apply from: 'dependencies.gradle'
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}
"""
}
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
}
shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}
jar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
if(usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
if(usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
}
}
runClient {
if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}
args(arguments)
jvmArgs(jvmArguments)
}
runServer {
args(arguments)
jvmArgs(jvmArguments)
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = projectJavaVersion
}
)
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace modVersion and minecraftVersion
expand "minecraftVersion": project.minecraft.version,
"modVersion": modVersion,
"modId": modId,
"modName": modName
}
if(usesMixins.toBoolean()) {
from refMap
}
// copy everything else that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
def getManifestAttributes() {
def manifestAttributes = [:]
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
}
if(coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
task shadowDevJar(type: ShadowJar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
target = tasks.shadowDevJar
prefix = modGroup + ".shadow"
}
task circularResolverJar(type: Jar) {
dependsOn(relocateShadowDevJar)
dependsOn(shadowDevJar)
enabled = false
}
task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
getArchiveClassifier().set('api')
}
artifacts {
if(!noPublishedSources) {
archives sourcesJar
}
archives devJar
if(apiPackage) {
archives apiJar
}
}
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
// and isn't strictly needed with the POM so just disable it.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
publishing {
publications {
maven(MavenPublication) {
from components.java
if(usesShadowedDependencies.toBoolean()) {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
artifact source: apiJar, classifier: "api"
}
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
// remove extra garbage from who knows where
pom.withXml {
def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang',
'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents',
'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava',
'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j',
'org.lwjgl.lwjgl', 'tv.twitch', 'org.jetbrains.kotlin', '']
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
badPomGroup.contains(it.groupId.text())
}.each() {
it.parent().remove(it)
}
}
}
}
repositories {
maven {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
return versionLine.split(": ").last()
}
return ""
}
configure(updateBuildScript) {
group = 'forgegradle'
description = 'Updates the build script to the latest version'
}
// Deobfuscation
def deobf(String sourceURL) {
try {
URL url = new URL(sourceURL)
String fileName = url.getFile()
//get rid of directories:
int lastSlash = fileName.lastIndexOf("/")
if(lastSlash > 0) {
fileName = fileName.substring(lastSlash + 1)
}
//get rid of extension:
if(fileName.endsWith(".jar")) {
fileName = fileName.substring(0, fileName.lastIndexOf("."))
}
String hostName = url.getHost()
if(hostName.startsWith("www.")) {
hostName = hostName.substring(4)
}
List parts = Arrays.asList(hostName.split("\\."))
Collections.reverse(parts)
hostName = String.join(".", parts)
return deobf(sourceURL, hostName + "/" + fileName)
} catch(Exception e) {
return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode()))
}
}
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String fileName) {
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
String bon2Dir = cacheDir + "forge_gradle/deobf"
String bon2File = bon2Dir + "/BON2-2.5.0.jar"
String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar"
String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar"
if(file(deobfFile).exists()) {
return files(deobfFile)
}
download.run {
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
dest bon2File
quiet true
overwrite false
}
download.run {
src sourceURL
dest obfFile
quiet true
overwrite false
}
exec {
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch'
workingDir bon2Dir
standardOutput = new ByteArrayOutputStream()
}
return files(deobfFile)
}
// Helper methods
def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
id 'com.gtnewhorizons.gtnhconvention'
}
+8 -5
View File
@@ -1,9 +1,12 @@
// Add your dependencies here
dependencies {
compile 'com.github.GTNewHorizons:ForestryMC:4.4.6:dev'
compileOnly 'com.github.GTNewHorizons:BuildCraft:7.1.27:api'
api('com.github.GTNewHorizons:ForestryMC:4.11.8:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.9.40:dev')
compileOnly 'net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev'
compileOnly 'curse.maven:cofh-lib-220333:2388748'
}
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.75-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
}
+195 -24
View File
@@ -1,64 +1,235 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Binnie Core
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = BinnieCore
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = binnie
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# Enables 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.
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = binnie.core.Tags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = BinnieCore.java
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = false
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
customArchiveBaseName = binnie-mods
# 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.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
+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/c5ee947fbfb70bc347d8d531e3a578c4/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5ee947fbfb70bc347d8d531e3a578c4/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/d4fd992c9557644e637ebe98263e0ae7/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/faa12903720d410b387cc69ccafb1a74/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5ee947fbfb70bc347d8d531e3a578c4/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3689d0bcdd77ac01674ba3c9dbbe94d0/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainVersion=25
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+178 -118
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or 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,80 +15,114 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# 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/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# This is normally unused
# 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 -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"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,92 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and 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" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+93 -100
View File
@@ -1,100 +1,93 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@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 ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
@rem Execute Gradle
"%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
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
-22
View File
@@ -1,26 +1,4 @@
// Add any additional repositories for your dependencies here
repositories {
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
name 'ic2'
url 'http://maven.ic2.player.to/'
metadataSources {
mavenPom()
artifact()
}
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
+21
View File
@@ -0,0 +1,21 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
}
+12 -15
View File
@@ -1,22 +1,19 @@
package binnie;
import binnie.core.ManagerBase;
import binnie.core.genetics.ManagerGenetics;
import binnie.core.item.ManagerItem;
import binnie.core.liquid.ManagerLiquid;
import binnie.core.machines.ManagerMachine;
import binnie.core.mod.config.ManagerConfig;
import binnie.core.resource.ManagerResource;
import java.util.ArrayList;
import java.util.List;
import binnie.core.ManagerBase;
import binnie.core.genetics.ManagerGenetics;
import binnie.core.liquid.ManagerLiquid;
import binnie.core.machines.ManagerMachine;
import binnie.core.resource.ManagerResource;
public final class Binnie {
public static List<ManagerBase> Managers = new ArrayList<>();
public static ManagerGenetics Genetics = new ManagerGenetics();
public static ManagerConfig Configuration = new ManagerConfig();
public static ManagerLiquid Liquid = new ManagerLiquid();
public static ManagerMachine Machine = new ManagerMachine();
public static ManagerItem Item = new ManagerItem();
public static ManagerResource Resource = new ManagerResource();
public static List<ManagerBase> Managers = new ArrayList<>();
public static ManagerGenetics Genetics = new ManagerGenetics();
public static ManagerLiquid Liquid = new ManagerLiquid();
public static ManagerMachine Machine = new ManagerMachine();
public static ManagerResource Resource = new ManagerResource();
}
+268 -259
View File
@@ -1,5 +1,16 @@
package binnie.botany;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.IFlower;
@@ -29,6 +40,7 @@ import binnie.botany.network.PacketID;
import binnie.botany.proxy.Proxy;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
import binnie.core.gui.IBinnieGUID;
import binnie.core.item.ItemMisc;
import binnie.core.network.BinniePacketHandler;
@@ -42,299 +54,296 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
@Mod(
modid = "Botany",
name = "Botany",
version = BinnieCore.VERSION,
useMetadata = true,
dependencies = "after:BinnieCore"
)
@Mod(modid = "Botany", name = "Botany", version = Tags.VERSION, useMetadata = true, dependencies = "after:BinnieCore")
public class Botany extends AbstractMod {
@Mod.Instance("Botany")
public static Botany instance;
@SidedProxy(
clientSide = "binnie.botany.proxy.ProxyClient",
serverSide = "binnie.botany.proxy.ProxyServer"
)
public static Proxy proxy;
@Mod.Instance("Botany")
public static Botany instance;
public static BlockFlower flower;
public static Item seed;
public static Item pollen;
public static ItemDictionary database;
public static BlockPlant plant;
public static ItemTrowel trowelWood;
public static ItemTrowel trowelStone;
public static ItemTrowel trowelIron;
public static ItemTrowel trowelDiamond;
public static ItemTrowel trowelGold;
public static BlockSoil soil;
public static BlockSoil loam;
public static BlockSoil flowerbed;
public static BlockSoil soilNoWeed;
public static BlockSoil loamNoWeed;
public static BlockSoil flowerbedNoWeed;
public static ItemInsulatedTube insulatedTube;
public static ItemSoilMeter soilMeter;
public static ItemMisc misc;
public static ItemFlower flowerItem;
public static ItemPigment pigment;
public static ItemClay clay;
public static BlockCeramic ceramic;
public static BlockCeramicPatterned ceramicTile;
public static BlockStained stained;
public static BlockCeramicBrick ceramicBrick;
@SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
public static Proxy proxy;
public Botany() {
Botany.instance = this;
}
// Genetics module
public static BlockFlower flower;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
addModule(new ModuleCore());
addModule(new ModuleGenetics());
addModule(new ModuleGardening());
preInit();
}
public static ItemFlower flowerItem;
public static Item pollen;
public static Item seed;
public static ItemDictionary database;
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
init();
}
// Gardening module
public static BlockPlant plant;
public static BlockSoil soil;
public static BlockSoil loam;
public static BlockSoil flowerbed;
public static BlockSoil soilNoWeed;
public static BlockSoil loamNoWeed;
public static BlockSoil flowerbedNoWeed;
public static BlockCeramic ceramic;
public static BlockStained stained;
public static BlockCeramicPatterned ceramicTile;
public static BlockCeramicBrick ceramicBrick;
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
postInit();
}
public static ItemSoilMeter soilMeter;
public static ItemInsulatedTube insulatedTube;
public static ItemTrowel trowelWood;
public static ItemTrowel trowelStone;
public static ItemTrowel trowelIron;
public static ItemTrowel trowelDiamond;
public static ItemTrowel trowelGold;
public static ItemMisc misc;
public static ItemPigment pigment;
public static ItemClay clay;
@Override
public IBinnieGUID[] getGUIDs() {
return BotanyGUI.values();
}
public Botany() {
Botany.instance = this;
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public Class<?>[] getConfigs() {
return new Class[0];
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
addModule(new ModuleCore());
addModule(new ModuleGenetics());
addModule(new ModuleGardening());
preInit();
}
@Override
public IPacketID[] getPacketIDs() {
return PacketID.values();
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
init();
}
@Override
public IProxyCore getProxy() {
return Botany.proxy;
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
postInit();
}
@Override
public String getChannel() {
return "BOT";
}
@Override
public IBinnieGUID[] getGUIDs() {
return BotanyGUI.values();
}
@Override
public String getModID() {
return "botany";
}
@Override
public IPacketID[] getPacketIDs() {
return PacketID.values();
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
}
@Override
public IProxyCore getProxy() {
return Botany.proxy;
}
@SubscribeEvent
public void onShearFlower(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
@Override
public String getChannel() {
return "BOT";
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
flower.onShear();
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
@Override
public String getModID() {
return "botany";
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (pollen != null && flower.canMateWith(pollen)) {
flower.mateWith(pollen);
if (!event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
}
}
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
}
@SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
return;
}
@Deprecated
public void onPlantVanilla(PlayerInteractEvent event) {
if (!BinnieCore.proxy.isSimulating(event.world)
|| event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y, z);
int py = -1;
if (block instanceof IBlockSoil
&& (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) {
py = 1;
}
int y = event.y;
Block block = event.world.getBlock(event.x, y, event.z);
if (block == null || !Gardening.isSoil(block)) {
block = event.world.getBlock(event.x, --y, event.z);
}
if (block == null || !Gardening.isSoil(block)) {
return;
}
if (py < 0) {
return;
}
IBlockSoil soil = (IBlockSoil) block;
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem()) && soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
int next = Math.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
return;
}
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.entityPlayer.getHeldItem());
if (flower != null && Gardening.plant(world, x, y + py, z, flower, event.entityPlayer.getGameProfile())
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem()) && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem2 = event.entityPlayer.getHeldItem();
heldItem2.stackSize--;
return;
}
}
@Mod.EventHandler
public void onIMC(FMLInterModComms.IMCEvent event) {
for (FMLInterModComms.IMCMessage message : event.getMessages()) {
if (message.key.equals("add-nutrient-fertiliser-1")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-nutrient-fertiliser-2")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 2);
}
if (message.key.equals("add-acid-fertiliser-1")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-acid-fertiliser-2")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 2);
}
if (message.key.equals("add-alkaline-fertiliser-1")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-alkaline-fertiliser-2")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
}
}
}
if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem()) && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
heldItem3.stackSize--;
return;
}
}
public static class PacketHandler extends BinniePacketHandler {
if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem()) && Gardening.addWeedKiller(event.world, event.x, y, event.z) && !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem4 = event.entityPlayer.getHeldItem();
heldItem4.stackSize--;
}
}
public PacketHandler() {
super(Botany.instance);
}
}
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y - 1, z);
if (!(block instanceof IBlockSoil)) {
return;
}
public static class EventHandler {
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
if (flower != null) {
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
}
}
@SubscribeEvent
public void onShearFlower(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
@Deprecated
public void onPlantVanilla(PlayerInteractEvent event) {
if (!BinnieCore.proxy.isSimulating(event.world) || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
tileFlower.onShear();
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y, z);
int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) {
py = 1;
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (pollen != null && tileFlower.canMateWith(pollen)) {
tileFlower.mateWith(pollen);
if (!event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
}
}
}
if (py < 0) {
return;
}
@SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
return;
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.entityPlayer.getHeldItem());
if (flower != null && Gardening.plant(world, x, y + py, z, flower, event.entityPlayer.getGameProfile()) && !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
@SubscribeEvent
public void onBonemeal(BonemealEvent event) {
Block block = event.world.getBlock(event.x, event.y, event.z);
if (Gardening.isSoil(block)) {
IBlockSoil soil = (IBlockSoil) block;
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
event.setResult(Event.Result.ALLOW);
}
}
int y = event.y;
Block block = event.world.getBlock(event.x, y, event.z);
if (!Gardening.isSoil(block)) {
block = event.world.getBlock(event.x, --y, event.z);
}
if (!Gardening.isSoil(block)) {
return;
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
event.setResult(Event.Result.ALLOW);
}
}
IBlockSoil soil = (IBlockSoil) block;
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem())
&& soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
int next = Math
.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.VALUES[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
return;
}
}
@Override
public boolean isActive() {
return BinnieCore.isBotanyActive();
}
if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.VALUES[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem2 = event.entityPlayer.getHeldItem();
heldItem2.stackSize--;
return;
}
}
@Mod.EventHandler
public void onIMC(FMLInterModComms.IMCEvent event) {
for (FMLInterModComms.IMCMessage message : event.getMessages()) {
if (message.key.equals("add-nutrient-fertiliser-1")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-nutrient-fertiliser-2")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 2);
}
if (message.key.equals("add-acid-fertiliser-1")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-acid-fertiliser-2")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 2);
}
if (message.key.equals("add-alkaline-fertiliser-1")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
}
if (message.key.equals("add-alkaline-fertiliser-2")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
}
}
}
if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.VALUES[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
heldItem3.stackSize--;
return;
}
}
public static class PacketHandler extends BinniePacketHandler {
public PacketHandler() {
super(Botany.instance);
}
}
if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem())
&& Gardening.addWeedKiller(event.world, event.x, y, event.z)
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem4 = event.entityPlayer.getHeldItem();
heldItem4.stackSize--;
}
}
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y - 1, z);
if (!(block instanceof IBlockSoil)) {
return;
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
if (flower != null) {
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
}
}
@SubscribeEvent
public void onBonemeal(BonemealEvent event) {
Block block = event.world.getBlock(event.x, event.y, event.z);
if (Gardening.isSoil(block)) {
IBlockSoil soil = (IBlockSoil) block;
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
event.setResult(Event.Result.ALLOW);
}
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
event.setResult(Event.Result.ALLOW);
}
}
}
}
@@ -1,39 +1,41 @@
package binnie.botany;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CreativeTabBotany extends CreativeTabs {
public static CreativeTabs instance = new CreativeTabBotany();
public CreativeTabBotany() {
super("Botany");
}
public static CreativeTabs instance = new CreativeTabBotany();
@Override
public ItemStack getIconItemStack() {
return new ItemStack(Blocks.red_flower, 1, 5);
}
public CreativeTabBotany() {
super("Botany");
}
@Override
public String getTranslatedTabLabel() {
return getTabLabel();
}
@Override
public ItemStack getIconItemStack() {
return new ItemStack(Blocks.red_flower, 1, 5);
}
@Override
@SideOnly(Side.CLIENT)
public String getTabLabel() {
return I18N.localise("botany.tab.botany");
}
@Override
public String getTranslatedTabLabel() {
return getTabLabel();
}
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.yellow_flower);
}
@Override
@SideOnly(Side.CLIENT)
public String getTabLabel() {
return I18N.localise("botany.tab.botany");
}
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.yellow_flower);
}
}
@@ -1,11 +1,17 @@
package binnie.botany.api;
public enum EnumAcidity {
ACID,
NEUTRAL,
ALKALINE;
public String getID() {
return name().toLowerCase();
}
ACID,
NEUTRAL,
ALKALINE;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumAcidity[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
}
@@ -10,37 +10,42 @@ import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
public enum EnumFlowerChromosome implements IChromosomeType {
SPECIES(IAlleleFlowerSpecies.class),
PRIMARY(IAlleleInteger.class),
SECONDARY(IAlleleInteger.class),
FERTILITY(IAlleleInteger.class),
TERRITORY(IAlleleArea.class),
EFFECT(IAlleleFlowerEffect.class),
LIFESPAN(IAlleleInteger.class),
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
PH_TOLERANCE(IAlleleTolerance.class),
SAPPINESS(IAlleleFloat.class),
STEM(IAlleleInteger.class);
private Class<? extends IAllele> cls;
SPECIES(IAlleleFlowerSpecies.class),
PRIMARY(IAlleleInteger.class),
SECONDARY(IAlleleInteger.class),
FERTILITY(IAlleleInteger.class),
TERRITORY(IAlleleArea.class),
EFFECT(IAlleleFlowerEffect.class),
LIFESPAN(IAlleleInteger.class),
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
PH_TOLERANCE(IAlleleTolerance.class),
SAPPINESS(IAlleleFloat.class),
STEM(IAlleleInteger.class);
EnumFlowerChromosome(Class<? extends IAllele> cls) {
this.cls = cls;
}
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumFlowerChromosome[] VALUES = values();
private final Class<? extends IAllele> cls;
@Override
public Class<? extends IAllele> getAlleleClass() {
return cls;
}
EnumFlowerChromosome(Class<? extends IAllele> cls) {
this.cls = cls;
}
@Override
public String getName() {
return toString().toLowerCase();
}
@Override
public Class<? extends IAllele> getAlleleClass() {
return cls;
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
}
@Override
public String getName() {
return toString().toLowerCase();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
}
}
@@ -1,18 +1,19 @@
package binnie.botany.api;
public enum EnumFlowerStage {
FLOWER("Flower"),
SEED("Seed"),
POLLEN("Pollen"),
NONE("NONE");
protected String name;
FLOWER("Flower"),
SEED("Seed"),
POLLEN("Pollen"),
NONE("NONE");
EnumFlowerStage(String name) {
this.name = name;
}
private final String name;
public String getName() {
return name;
}
EnumFlowerStage(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@@ -1,11 +1,17 @@
package binnie.botany.api;
public enum EnumMoisture {
DRY,
NORMAL,
DAMP;
public String getID() {
return name().toLowerCase();
}
DRY,
NORMAL,
DAMP;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumMoisture[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
}
@@ -1,11 +1,17 @@
package binnie.botany.api;
public enum EnumSoilType {
SOIL,
LOAM,
FLOWERBED;
public String getID() {
return name().toLowerCase();
}
SOIL,
LOAM,
FLOWERBED;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumSoilType[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
}
@@ -1,9 +1,11 @@
package binnie.botany.api;
import net.minecraft.world.World;
import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IEffectData;
import net.minecraft.world.World;
public interface IAlleleFlowerEffect extends IAlleleEffect {
IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z);
IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z);
}
@@ -3,9 +3,10 @@ package binnie.botany.api;
import forestry.api.genetics.IAlleleSpecies;
public interface IAlleleFlowerSpecies extends IAlleleSpecies {
IFlowerType getType();
EnumAcidity getPH();
IFlowerType getType();
EnumMoisture getMoisture();
EnumAcidity getPH();
EnumMoisture getMoisture();
}
@@ -1,13 +1,14 @@
package binnie.botany.api;
public interface IColourMix {
IFlowerColor getColor1();
IFlowerColor getColor2();
IFlowerColor getColor1();
boolean isMutation(IFlowerColor color1, IFlowerColor color2);
IFlowerColor getColor2();
int getChance();
boolean isMutation(IFlowerColor color1, IFlowerColor color2);
IFlowerColor getResult();
int getChance();
IFlowerColor getResult();
}
+17 -15
View File
@@ -1,33 +1,35 @@
package binnie.botany.api;
import forestry.api.genetics.IIndividual;
import net.minecraft.world.World;
import forestry.api.genetics.IIndividual;
public interface IFlower extends IIndividual {
@Override
IFlowerGenome getGenome();
IFlowerGenome getMate();
@Override
IFlowerGenome getGenome();
void mate(IFlower other);
IFlowerGenome getMate();
int getAge();
void mate(IFlower other);
void setAge(int age);
int getAge();
void age();
void setAge(int age);
IFlower getOffspring(World world);
void age();
int getMaxAge();
IFlower getOffspring(World world);
boolean isWilted();
int getMaxAge();
void setWilted(boolean value);
boolean isWilted();
boolean hasFlowered();
void setWilted(boolean value);
void setFlowered(boolean value);
boolean hasFlowered();
void removeMate();
void setFlowered(boolean value);
void removeMate();
}
@@ -3,11 +3,12 @@ package binnie.botany.api;
import forestry.api.genetics.IAlleleInteger;
public interface IFlowerColor {
int getColor(boolean dis);
IAlleleInteger getAllele();
int getColor(boolean dis);
int getID();
IAlleleInteger getAllele();
String getName();
int getID();
String getName();
}
@@ -5,37 +5,38 @@ import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IGenome;
public interface IFlowerGenome extends IGenome {
@Override
IAlleleFlowerSpecies getPrimary();
@Override
IAlleleFlowerSpecies getSecondary();
@Override
IAlleleFlowerSpecies getPrimary();
IFlowerColor getPrimaryColor();
@Override
IAlleleFlowerSpecies getSecondary();
IFlowerColor getSecondaryColor();
IFlowerColor getPrimaryColor();
IFlowerColor getStemColor();
IFlowerColor getSecondaryColor();
int getFertility();
IFlowerColor getStemColor();
int getLifespan();
int getFertility();
IFlowerType getType();
int getLifespan();
EnumTolerance getToleranceTemperature();
IFlowerType getType();
EnumTolerance getToleranceMoisture();
EnumTolerance getToleranceTemperature();
EnumTolerance getTolerancePH();
EnumTolerance getToleranceMoisture();
float getAgeChance();
EnumTolerance getTolerancePH();
float getSappiness();
float getAgeChance();
boolean canTolerate(EnumAcidity pH);
float getSappiness();
boolean canTolerate(EnumMoisture moisture);
boolean canTolerate(EnumAcidity pH);
boolean canTolerate(EnumTemperature temp);
boolean canTolerate(EnumMoisture moisture);
boolean canTolerate(EnumTemperature temp);
}
@@ -5,5 +5,6 @@ import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
public interface IFlowerMutation extends IMutation {
float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
}
@@ -1,44 +1,47 @@
package binnie.botany.api;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
public interface IFlowerRoot extends ISpeciesRoot {
@Override
IFlower getMember(ItemStack stack);
@Override
IFlower templateAsIndividual(IAllele[] template);
@Override
IFlower getMember(ItemStack stack);
@Override
IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IFlower templateAsIndividual(IAllele[] template);
@Override
IFlowerGenome templateAsGenome(IAllele[] template);
@Override
IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IFlowerGenome templateAsGenome(IAllele[] template);
@Override
IBotanistTracker getBreedingTracker(World world, GameProfile player);
@Override
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
@Override
Collection<IFlowerMutation> getMutations(boolean shuffle);
@Override
IBotanistTracker getBreedingTracker(World world, GameProfile player);
EnumFlowerStage getStageType(ItemStack stack);
@Override
Collection<IFlowerMutation> getMutations(boolean shuffle);
IFlower getFlower(World world, IFlowerGenome genome);
EnumFlowerStage getStageType(ItemStack stack);
void addConversion(ItemStack stack, IAllele[] template);
IFlower getFlower(World world, IFlowerGenome genome);
IFlower getConversion(ItemStack stack);
void addConversion(ItemStack stack, IAllele[] template);
Collection<IColourMix> getColourMixes(boolean shuffle);
IFlower getConversion(ItemStack stack);
void registerColourMix(IColourMix colorMix);
Collection<IColourMix> getColourMixes(boolean shuffle);
void registerColourMix(IColourMix colorMix);
}
@@ -3,15 +3,16 @@ package binnie.botany.api;
import net.minecraft.util.IIcon;
public interface IFlowerType {
IIcon getStem(EnumFlowerStage stage, boolean flowered, int section);
IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section);
IIcon getStem(EnumFlowerStage stage, boolean flowered, int section);
IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section);
IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section);
int getID();
IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section);
int getSections();
int getID();
int ordinal();
int getSections();
int ordinal();
}
@@ -1,24 +1,26 @@
package binnie.botany.api.gardening;
import net.minecraft.world.World;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import net.minecraft.world.World;
public interface IBlockSoil {
EnumAcidity getPH(World world, int x, int y, int z);
EnumMoisture getMoisture(World world, int x, int y, int z);
EnumAcidity getPH(World world, int x, int y, int z);
EnumSoilType getType(World world, int x, int y, int z);
EnumMoisture getMoisture(World world, int x, int y, int z);
boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel);
EnumSoilType getType(World world, int x, int y, int z);
boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel);
boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel);
boolean setPH(World world, int x, int y, int z, EnumAcidity pH);
boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel);
boolean setMoisture(World world, int x, int y, int z, EnumMoisture p4);
boolean setPH(World world, int x, int y, int z, EnumAcidity pH);
boolean resistsWeeds(World world, int x, int y, int z);
boolean setMoisture(World world, int x, int y, int z, EnumMoisture p4);
boolean resistsWeeds(World world, int x, int y, int z);
}
@@ -1,14 +1,8 @@
package binnie.botany.ceramic;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.BlockMetadata;
import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -24,123 +18,131 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.BlockMetadata;
import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCeramic extends Block implements IBlockMetadata {
public BlockCeramic() {
super(Material.rock);
setHardness(1.0f);
setResistance(5.0f);
setBlockName("ceramic");
setCreativeTab(CreativeTabBotany.instance);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
}
public BlockCeramic() {
super(Material.rock);
setHardness(1.0f);
setResistance(5.0f);
setBlockName("ceramic");
setCreativeTab(CreativeTabBotany.instance);
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata();
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z);
}
@Override
public boolean hasTileEntity(int meta) {
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata();
}
@Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
}
@Override
public boolean hasTileEntity(int meta) {
return true;
}
@Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack);
}
@Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
}
@Override
public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta;
}
@Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack);
}
@Override
public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.ceramicBlock");
}
@Override
public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta;
}
@Override
public void addBlockTooltip(ItemStack stack, List tooltip) {
int meta = TileEntityMetadata.getItemDamage(stack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
}
@Override
public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.ceramicBlock");
}
@Override
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
dropBlockAsItem(world, x, y, z, itemStack);
}
@Override
public void addBlockTooltip(ItemStack stack, List<String> tooltip) {
int meta = TileEntityMetadata.getItemDamage(stack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
}
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List itemList) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@Override
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
dropBlockAsItem(world, x, y, z, itemStack);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getIcon(side, tile.getTileMetadata());
}
return super.getIcon(world, x, y, z, side);
}
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@Override
public IIcon getIcon(int side, int meta) {
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getIcon(side, tile.getTileMetadata());
}
return super.getIcon(world, x, y, z, side);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "ceramic");
}
@Override
public IIcon getIcon(int side, int meta) {
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getRenderColor(tile.getTileMetadata());
}
return 0xffffff;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "ceramic");
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getRenderColor(tile.getTileMetadata());
}
return 0xffffff;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false);
}
}
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,11 @@
package binnie.botany.ceramic;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.TileEntityMetadata;
@@ -8,35 +14,35 @@ import binnie.extratrees.api.IDesign;
import binnie.extratrees.carpentry.BlockDesign;
import binnie.extratrees.carpentry.DesignBlock;
import binnie.extratrees.carpentry.ModuleCarpentry;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import java.util.List;
public class BlockCeramicPatterned extends BlockDesign {
public BlockCeramicPatterned() {
super(CeramicDesignSystem.instance, Material.rock);
setHardness(1.0f);
setResistance(5.0f);
setCreativeTab(CreativeTabBotany.instance);
setBlockName("ceramicPattern");
}
@Override
public ItemStack getCreativeStack(IDesign design) {
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.WHITE), CeramicColor.get(EnumFlowerColor.BLACK), design);
}
public BlockCeramicPatterned() {
super(CeramicDesignSystem.instance, Material.rock);
setHardness(1.0f);
setResistance(5.0f);
setCreativeTab(CreativeTabBotany.instance);
setBlockName("ceramicPattern");
}
@Override
public String getBlockName(DesignBlock design) {
return I18N.localise("botany.ceramicBlock");
}
@Override
public ItemStack getCreativeStack(IDesign design) {
return ModuleCarpentry.getItemStack(
this,
CeramicColor.get(EnumFlowerColor.WHITE),
CeramicColor.get(EnumFlowerColor.BLACK),
design);
}
@Override
public void addBlockTooltip(ItemStack stack, List tooltip) {
super.addBlockTooltip(stack, tooltip);
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
tooltip.add(EnumChatFormatting.GRAY + block.getDesign().getName());
}
@Override
public String getBlockName(DesignBlock design) {
return I18N.localise("botany.ceramicBlock");
}
@Override
public void addBlockTooltip(ItemStack stack, List<String> tooltip) {
super.addBlockTooltip(stack, tooltip);
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
tooltip.add(EnumChatFormatting.GRAY + block.getDesign().getName());
}
}
@@ -1,15 +1,9 @@
package binnie.botany.ceramic;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.BlockMetadata;
import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.core.util.I18N;
import binnie.extratrees.ExtraTrees;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -25,173 +19,181 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.BlockMetadata;
import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.core.util.I18N;
import binnie.extratrees.ExtraTrees;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockStained extends Block implements IBlockMetadata {
public BlockStained() {
super(Material.glass);
setCreativeTab(CreativeTabBotany.instance);
setBlockName("stained");
}
@Override
public int quantityDropped(Random rand) {
return 0;
}
public BlockStained() {
super(Material.glass);
setHardness(0.3f);
setCreativeTab(CreativeTabBotany.instance);
setBlockName("stained");
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int quantityDropped(Random rand) {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 1;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
// Block block2 = world.getBlock(x - Facing.offsetsXForSide[side], y - Facing.offsetsYForSide[side], z - Facing.offsetsZForSide[side]);
Block block = world.getBlock(x, y, z);
return block != this
&& block != ExtraTrees.blockStained
&& super.shouldSideBeRendered(world, x, y, z, side);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 1;
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
// Block block2 = world.getBlock(x - Facing.offsetsXForSide[side], y - Facing.offsetsYForSide[side], z -
// Facing.offsetsZForSide[side]);
Block block = world.getBlock(x, y, z);
return block != this && block != ExtraTrees.blockStained && super.shouldSideBeRendered(world, x, y, z, side);
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata();
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z);
}
@Override
public boolean hasTileEntity(int meta) {
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata();
}
@Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
}
@Override
public boolean hasTileEntity(int meta) {
return true;
}
@Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack);
}
@Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
}
@Override
public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta;
}
@Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack);
}
@Override
public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.pigmentedGlass");
}
@Override
public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta;
}
@Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
int meta = TileEntityMetadata.getItemDamage(itemStack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
}
@Override
public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.pigmentedGlass");
}
@Override
public void dropAsStack(World world, int x, int y, int z, ItemStack stack) {
dropBlockAsItem(world, x, y, z, stack);
}
@Override
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
int meta = TileEntityMetadata.getItemDamage(itemStack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@Override
public void dropAsStack(World world, int x, int y, int z, ItemStack stack) {
dropBlockAsItem(world, x, y, z, stack);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getIcon(side, tile.getTileMetadata());
}
return super.getIcon(world, x, y, z, side);
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@Override
public IIcon getIcon(int side, int meta) {
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getIcon(side, tile.getTileMetadata());
}
return super.getIcon(world, x, y, z, side);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "stained");
}
@Override
public IIcon getIcon(int side, int meta) {
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getRenderColor(tile.getTileMetadata());
}
return 0xffffff;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "stained");
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) {
return getRenderColor(tile.getTileMetadata());
}
return 0xffffff;
}
@Override
public boolean isWood(IBlockAccess world, int x, int y, int z) {
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z);
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 20;
}
@Override
public boolean isWood(IBlockAccess world, int x, int y, int z) {
return true;
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return true;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 20;
}
@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 5;
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return true;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z);
}
@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 5;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false);
}
}
@@ -1,46 +1,48 @@
package binnie.botany.ceramic;
import java.util.LinkedHashMap;
import java.util.Map;
import net.minecraft.item.ItemStack;
import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.TileEntityMetadata;
import binnie.extratrees.api.IDesignMaterial;
import net.minecraft.item.ItemStack;
import java.util.LinkedHashMap;
import java.util.Map;
public class CeramicColor implements IDesignMaterial {
private static Map<EnumFlowerColor, CeramicColor> map;
static {
CeramicColor.map = new LinkedHashMap<>();
for (EnumFlowerColor c : EnumFlowerColor.values()) {
CeramicColor.map.put(c, new CeramicColor(c));
}
}
private static Map<EnumFlowerColor, CeramicColor> map;
protected EnumFlowerColor color;
static {
CeramicColor.map = new LinkedHashMap<>();
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
CeramicColor.map.put(c, new CeramicColor(c));
}
}
CeramicColor(EnumFlowerColor color) {
this.color = color;
}
protected EnumFlowerColor color;
public static CeramicColor get(EnumFlowerColor c) {
return CeramicColor.map.get(c);
}
CeramicColor(EnumFlowerColor color) {
this.color = color;
}
@Override
public ItemStack getStack() {
return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal());
}
public static CeramicColor get(EnumFlowerColor c) {
return CeramicColor.map.get(c);
}
@Override
public String getName() {
return color.getName();
}
@Override
public ItemStack getStack() {
return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal());
}
@Override
public int getColor() {
return color.getColor(false);
}
@Override
public String getName() {
return color.getName();
}
@Override
public int getColor() {
return color.getColor(false);
}
}
@@ -1,5 +1,13 @@
package binnie.botany.ceramic;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.items.BotanyItems;
@@ -10,85 +18,89 @@ import binnie.extratrees.api.IDesignSystem;
import binnie.extratrees.api.IPattern;
import binnie.extratrees.carpentry.DesignerManager;
import binnie.extratrees.carpentry.EnumPattern;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.HashMap;
import java.util.Map;
public class CeramicDesignSystem implements IDesignSystem {
public static CeramicDesignSystem instance = new CeramicDesignSystem();
protected Map<Integer, IIcon> primary;
protected Map<Integer, IIcon> secondary;
public static CeramicDesignSystem instance = new CeramicDesignSystem();
CeramicDesignSystem() {
primary = new HashMap<>();
secondary = new HashMap<>();
DesignerManager.instance.registerDesignSystem(this);
}
protected Map<Integer, IIcon> primary;
protected Map<Integer, IIcon> secondary;
@Override
public IDesignMaterial getDefaultMaterial() {
return CeramicColor.get(EnumFlowerColor.WHITE);
}
CeramicDesignSystem() {
primary = new HashMap<>();
secondary = new HashMap<>();
DesignerManager.instance.registerDesignSystem(this);
}
@Override
public IDesignMaterial getDefaultMaterial2() {
return CeramicColor.get(EnumFlowerColor.BLACK);
}
@Override
public IDesignMaterial getDefaultMaterial() {
return CeramicColor.get(EnumFlowerColor.WHITE);
}
@Override
public IDesignMaterial getMaterial(int id) {
return CeramicColor.get(EnumFlowerColor.get(id));
}
@Override
public IDesignMaterial getDefaultMaterial2() {
return CeramicColor.get(EnumFlowerColor.BLACK);
}
@Override
public int getMaterialIndex(IDesignMaterial id) {
return ((CeramicColor) id).color.ordinal();
}
@Override
public IDesignMaterial getMaterial(int id) {
return CeramicColor.get(EnumFlowerColor.get(id));
}
public String getTexturePath() {
return "ceramic";
}
@Override
public int getMaterialIndex(IDesignMaterial id) {
return ((CeramicColor) id).color.ordinal();
}
@Override
public IIcon getPrimaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return primary.get(((EnumPattern) pattern).ordinal());
}
return null;
}
public String getTexturePath() {
return "ceramic";
}
@Override
public IIcon getSecondaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return secondary.get(((EnumPattern) pattern).ordinal());
}
return null;
}
@Override
public IIcon getPrimaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return primary.get(((EnumPattern) pattern).ordinal());
}
return null;
}
@Override
public void registerIcons(IIconRegister register) {
for (EnumPattern pattern : EnumPattern.values()) {
primary.put(pattern.ordinal(), BinnieCore.proxy.getIcon(register, getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0"));
secondary.put(pattern.ordinal(), BinnieCore.proxy.getIcon(register, getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1"));
}
}
@Override
public IIcon getSecondaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return secondary.get(((EnumPattern) pattern).ordinal());
}
return null;
}
public AbstractMod getMod() {
return Botany.instance;
}
@Override
public void registerIcons(IIconRegister register) {
for (EnumPattern pattern : EnumPattern.VALUES) {
primary.put(
pattern.ordinal(),
BinnieCore.proxy.getIcon(
register,
getMod().getModID(),
getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0"));
secondary.put(
pattern.ordinal(),
BinnieCore.proxy.getIcon(
register,
getMod().getModID(),
getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1"));
}
}
@Override
public ItemStack getAdhesive() {
return BotanyItems.Mortar.get(1);
}
public AbstractMod getMod() {
return Botany.instance;
}
@Override
public IDesignMaterial getMaterial(ItemStack stack) {
return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null;
}
@Override
public ItemStack getAdhesive() {
return BotanyItems.Mortar.get(1);
}
@Override
public IDesignMaterial getMaterial(ItemStack stack) {
return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null;
}
}
@@ -1,71 +1,73 @@
package binnie.botany.ceramic;
import binnie.botany.Botany;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import binnie.botany.Botany;
public class CeramicTileRecipe implements IRecipe {
protected ItemStack cached;
@Override
public boolean matches(InventoryCrafting crafting, World world) {
cached = getCraftingResult(crafting);
return cached != null;
}
protected ItemStack cached;
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
Item mortar = Botany.misc;
List<ItemStack> stacks = new ArrayList<>();
int ix = -1;
int iy = -1;
@Override
public boolean matches(InventoryCrafting crafting, World world) {
cached = getCraftingResult(crafting);
return cached != null;
}
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null) {
int x = i / 3;
int y = i % 3;
if (ix == -1) {
ix = x;
iy = y;
}
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
return null;
}
Item item = stack.getItem();
if (item != ceramicBlock && item != ceramicTile && item != ceramicBrick && item != mortar) {
return null;
}
stacks.add(stack);
}
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
Item mortar = Botany.misc;
List<ItemStack> stacks = new ArrayList<>();
int ix = -1;
int iy = -1;
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
ItemStack stack2 = type.getRecipe(stacks);
if (stack2 != null) {
return stack2;
}
}
return null;
}
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null) {
int x = i / 3;
int y = i % 3;
if (ix == -1) {
ix = x;
iy = y;
}
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
return null;
}
@Override
public int getRecipeSize() {
return 2;
}
Item item = stack.getItem();
if (item != ceramicBlock && item != ceramicTile && item != ceramicBrick && item != mortar) {
return null;
}
stacks.add(stack);
}
}
@Override
public ItemStack getRecipeOutput() {
return cached;
}
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.VALUES) {
ItemStack stack2 = type.getRecipe(stacks);
if (stack2 != null) {
return stack2;
}
}
return null;
}
@Override
public int getRecipeSize() {
return 2;
}
@Override
public ItemStack getRecipeOutput() {
return cached;
}
}
@@ -1,59 +1,61 @@
package binnie.botany.ceramic;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.IFlower;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.IFlower;
public class PigmentRecipe implements IRecipe {
protected ItemStack cached;
private ItemStack unknown;
protected ItemStack cached;
public PigmentRecipe() {
unknown = null;
}
private final ItemStack unknown;
@Override
public boolean matches(InventoryCrafting crafting, World world) {
return getCraftingResult(crafting) != null;
}
public PigmentRecipe() {
unknown = null;
}
@Override
public ItemStack getRecipeOutput() {
if (cached != null) {
return cached;
}
return unknown;
}
@Override
public boolean matches(InventoryCrafting crafting, World world) {
return getCraftingResult(crafting) != null;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
int n = 0;
ItemStack stack = null;
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
if (crafting.getStackInSlot(i) != null) {
if (++n > 1) {
return null;
}
if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) {
continue;
}
@Override
public ItemStack getRecipeOutput() {
if (cached != null) {
return cached;
}
return unknown;
}
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i));
if (flower.getAge() >= 1) {
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
}
}
}
return stack;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
int n = 0;
ItemStack stack = null;
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
if (crafting.getStackInSlot(i) != null) {
if (++n > 1) {
return null;
}
if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) {
continue;
}
@Override
public int getRecipeSize() {
return 1;
}
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i));
if (flower.getAge() >= 1) {
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
}
}
}
return stack;
}
@Override
public int getRecipeSize() {
return 1;
}
}
@@ -4,9 +4,10 @@ import binnie.botany.api.IFlowerRoot;
import binnie.botany.genetics.FlowerHelper;
public class BotanyCore {
public static IFlowerRoot speciesRoot = new FlowerHelper();
public static IFlowerRoot getFlowerRoot() {
return BotanyCore.speciesRoot;
}
public static IFlowerRoot speciesRoot = new FlowerHelper();
public static IFlowerRoot getFlowerRoot() {
return BotanyCore.speciesRoot;
}
}
+18 -16
View File
@@ -1,26 +1,28 @@
package binnie.botany.core;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import binnie.botany.craftgui.WindowBotanistDatabase;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.gui.IBinnieGUID;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public enum BotanyGUI implements IBinnieGUID {
Database,
DatabaseNEI;
@Override
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
Window window = null;
switch (this) {
case Database:
case DatabaseNEI: {
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
break;
}
}
return window;
}
Database,
DatabaseNEI;
@Override
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
Window window = null;
switch (this) {
case Database:
case DatabaseNEI: {
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
break;
}
}
return window;
}
}
@@ -3,18 +3,19 @@ package binnie.botany.core;
import binnie.core.IInitializable;
public class ModuleCore implements IInitializable {
@Override
public void preInit() {
// ignored
}
@Override
public void init() {
// ignored
}
@Override
public void preInit() {
// ignored
}
@Override
public void postInit() {
// ignored
}
@Override
public void init() {
// ignored
}
@Override
public void postInit() {
// ignored
}
}
@@ -11,33 +11,34 @@ import binnie.core.craftgui.controls.core.IControlValue;
import binnie.core.craftgui.geometry.IArea;
public class ControlColorDisplay extends Control implements IControlValue<IFlowerColor>, ITooltip {
private IFlowerColor value;
public ControlColorDisplay(IWidget parent, float x, float y) {
super(parent, x, y, 16.0f, 16.0f);
addAttribute(WidgetAttribute.MOUSE_OVER);
}
private IFlowerColor value;
@Override
public IFlowerColor getValue() {
return value;
}
public ControlColorDisplay(IWidget parent, float x, float y) {
super(parent, x, y, 16.0f, 16.0f);
addAttribute(WidgetAttribute.MOUSE_OVER);
}
@Override
public void setValue(IFlowerColor value) {
this.value = value;
}
@Override
public IFlowerColor getValue() {
return value;
}
@Override
public void onRenderBackground() {
IArea area = getArea();
CraftGUI.render.solid(area, -1);
CraftGUI.render.solid(area.inset(1), 0xff000000 + getValue().getColor(false));
}
@Override
public void setValue(IFlowerColor value) {
this.value = value;
}
@Override
public void getTooltip(Tooltip tooltip) {
super.getTooltip(tooltip);
tooltip.add(value.getName());
}
@Override
public void onRenderBackground() {
IArea area = getArea();
CraftGUI.render.solid(area, -1);
CraftGUI.render.solid(area.inset(1), 0xff000000 + getValue().getColor(false));
}
@Override
public void getTooltip(Tooltip tooltip) {
super.getTooltip(tooltip);
tooltip.add(value.getName());
}
}
@@ -5,20 +5,21 @@ import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.listbox.ControlListBox;
public class ControlColorMixBox extends ControlListBox<IColourMix> {
private Type type;
public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) {
super(parent, x, y, width, height, 12.0f);
this.type = type;
}
private final Type type;
@Override
public IWidget createOption(IColourMix value, int y) {
return new ControlColorMixItem(getContent(), value, y);
}
public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) {
super(parent, x, y, width, height, 12.0f);
this.type = type;
}
enum Type {
Resultant,
Further
}
@Override
public IWidget createOption(IColourMix value, int y) {
return new ControlColorMixItem(getContent(), value, y);
}
public enum Type {
Resultant,
Further
}
}
@@ -5,26 +5,27 @@ import binnie.core.craftgui.controls.listbox.ControlList;
import binnie.core.craftgui.controls.listbox.ControlOption;
public class ControlColorMixItem extends ControlOption<IColourMix> {
protected ControlColorDisplay itemWidget1;
protected ControlColorDisplay itemWidget2;
protected ControlColorDisplay itemWidget3;
protected ControlColourMixSymbol addSymbol;
protected ControlColourMixSymbol arrowSymbol;
public ControlColorMixItem(ControlList<IColourMix> controlList, IColourMix option, int y) {
super(controlList, option, y);
itemWidget1 = new ControlColorDisplay(this, 4.0f, 4.0f);
itemWidget2 = new ControlColorDisplay(this, 44.0f, 4.0f);
itemWidget3 = new ControlColorDisplay(this, 104.0f, 4.0f);
addSymbol = new ControlColourMixSymbol(this, 24, 4, 0);
arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1);
protected ControlColorDisplay itemWidget1;
protected ControlColorDisplay itemWidget2;
protected ControlColorDisplay itemWidget3;
protected ControlColourMixSymbol addSymbol;
protected ControlColourMixSymbol arrowSymbol;
if (getValue() != null) {
itemWidget1.setValue(getValue().getColor1());
itemWidget2.setValue(getValue().getColor2());
itemWidget3.setValue(getValue().getResult());
addSymbol.setValue(getValue());
arrowSymbol.setValue(getValue());
}
}
public ControlColorMixItem(ControlList<IColourMix> controlList, IColourMix option, int y) {
super(controlList, option, y);
itemWidget1 = new ControlColorDisplay(this, 4.0f, 4.0f);
itemWidget2 = new ControlColorDisplay(this, 44.0f, 4.0f);
itemWidget3 = new ControlColorDisplay(this, 104.0f, 4.0f);
addSymbol = new ControlColourMixSymbol(this, 24, 4, 0);
arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1);
if (getValue() != null) {
itemWidget1.setValue(getValue().getColor1());
itemWidget2.setValue(getValue().getColor2());
itemWidget3.setValue(getValue().getResult());
addSymbol.setValue(getValue());
arrowSymbol.setValue(getValue());
}
}
}
@@ -9,20 +9,21 @@ import binnie.core.craftgui.geometry.CraftGUIUtil;
import binnie.core.craftgui.geometry.IPoint;
public class ControlColorOption extends ControlTextOption<IFlowerColor> {
protected ControlColorDisplay controlBee;
protected IPoint boxPosition;
public ControlColorOption(ControlList<IFlowerColor> controlList, IFlowerColor option, int y) {
super(controlList, option, option.getName(), y);
setSize(new IPoint(getSize().x(), 20.0f));
(controlBee = new ControlColorDisplay(this, 2.0f, 2.0f)).setValue(option);
addAttribute(WidgetAttribute.MOUSE_OVER);
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
int th = (int) CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x());
int height = Math.max(20, th + 6);
setSize(new IPoint(size().x(), height));
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
boxPosition = new IPoint(2.0f, (height - 18) / 2);
}
protected ControlColorDisplay controlBee;
protected IPoint boxPosition;
public ControlColorOption(ControlList<IFlowerColor> controlList, IFlowerColor option, int y) {
super(controlList, option, option.getName(), y);
setSize(new IPoint(getSize().x(), 20.0f));
(controlBee = new ControlColorDisplay(this, 2.0f, 2.0f)).setValue(option);
addAttribute(WidgetAttribute.MOUSE_OVER);
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
int th = (int) CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x());
int height = Math.max(20, th + 6);
setSize(new IPoint(size().x(), height));
textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
boxPosition = new IPoint(2.0f, (height - 18) / 2);
}
}
@@ -14,39 +14,40 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.util.I18N;
public class ControlColourMixSymbol extends Control implements ITooltip {
protected static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
protected static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
protected IColourMix value;
protected int type;
protected static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
protected static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
protected ControlColourMixSymbol(IWidget parent, int x, int y, int type) {
super(parent, x, y, 16 + type * 16, 16.0f);
this.type = type;
value = null;
addAttribute(WidgetAttribute.MOUSE_OVER);
}
protected IColourMix value;
protected int type;
@Override
public void onRenderBackground() {
super.onRenderBackground();
if (type == 0) {
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
} else {
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
}
}
protected ControlColourMixSymbol(IWidget parent, int x, int y, int type) {
super(parent, x, y, 16 + type * 16, 16.0f);
this.type = type;
value = null;
addAttribute(WidgetAttribute.MOUSE_OVER);
}
public void setValue(IColourMix value) {
this.value = value;
setColor(0xffffff);
}
@Override
public void onRenderBackground() {
super.onRenderBackground();
if (type == 0) {
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
} else {
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
}
}
@Override
public void getTooltip(Tooltip tooltip) {
if (type == 1) {
float chance = value.getChance();
tooltip.add(I18N.localise("botany.gui.controls.colorMixSymbol.chance", chance));
}
}
public void setValue(IColourMix value) {
this.value = value;
setColor(0xffffff);
}
@Override
public void getTooltip(Tooltip tooltip) {
if (type == 1) {
float chance = value.getChance();
tooltip.add(I18N.localise("botany.gui.controls.colorMixSymbol.chance", chance));
}
}
}
@@ -1,5 +1,8 @@
package binnie.botany.craftgui;
import java.util.ArrayList;
import java.util.List;
import binnie.botany.api.IColourMix;
import binnie.botany.api.IFlowerColor;
import binnie.botany.core.BotanyCore;
@@ -10,27 +13,25 @@ import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageAbstract;
import binnie.core.util.I18N;
import java.util.ArrayList;
import java.util.List;
public class PageColorMix extends PageAbstract<IFlowerColor> {
ControlText title;
ControlColorMixBox list;
public PageColorMix(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageColorFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further);
}
ControlText title;
ControlColorMixBox list;
@Override
public void onValueChanged(IFlowerColor colour) {
List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getColor1() == colour || mix.getColor2() == colour) {
mixes.add(mix);
}
}
list.setOptions(mixes);
}
public PageColorMix(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageColorFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further);
}
@Override
public void onValueChanged(IFlowerColor colour) {
List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getColor1() == colour || mix.getColor2() == colour) {
mixes.add(mix);
}
}
list.setOptions(mixes);
}
}
@@ -1,5 +1,8 @@
package binnie.botany.craftgui;
import java.util.ArrayList;
import java.util.List;
import binnie.botany.api.IColourMix;
import binnie.botany.api.IFlowerColor;
import binnie.botany.core.BotanyCore;
@@ -10,27 +13,25 @@ import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageAbstract;
import binnie.core.util.I18N;
import java.util.ArrayList;
import java.util.List;
public class PageColorMixResultant extends PageAbstract<IFlowerColor> {
protected ControlText title;
protected ControlColorMixBox list;
public PageColorMixResultant(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageSpeciesFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant);
}
protected ControlText title;
protected ControlColorMixBox list;
@Override
public void onValueChanged(IFlowerColor color) {
List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getResult() == color) {
mixes.add(mix);
}
}
list.setOptions(mixes);
}
public PageColorMixResultant(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageSpeciesFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant);
}
@Override
public void onValueChanged(IFlowerColor color) {
List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getResult() == color) {
mixes.add(mix);
}
}
list.setOptions(mixes);
}
}
@@ -1,5 +1,7 @@
package binnie.botany.craftgui;
import net.minecraft.item.ItemStack;
import binnie.Binnie;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.EnumFlowerStage;
@@ -22,87 +24,143 @@ import binnie.genetics.genetics.AlleleHelper;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import net.minecraft.item.ItemStack;
public class PageSpeciesFlowerGenome extends PageSpecies {
public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
}
@Override
public void onValueChanged(IAlleleSpecies species) {
deleteAllChildren();
IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
}
IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
if (tree == null) {
return;
}
@Override
public void onValueChanged(IAlleleSpecies species) {
deleteAllChildren();
IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID());
if (template == null) {
return;
}
IFlowerGenome genome = tree.getGenome();
IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
int w = 144;
int h = 176;
IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
if (tree == null) {
return;
}
new ControlText(this, new IArea(0.0f, 4.0f, w, 16.0f), I18N.localise("botany.gui.database.tab.genome"), TextJustification.MIDDLE_CENTER);
ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f);
Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16);
IFlowerGenome genome = tree.getGenome();
IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
int w = 144;
int h = 176;
int tw = w - 8 - 12;
int w2 = 55;
int w3 = tw - 50;
int y = 0;
int th = 14;
int valueX = w2 + 4;
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.temp"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getTemperature()), TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(
this,
new IArea(0.0f, 4.0f, w, 16.0f),
I18N.localise("botany.gui.database.tab.genome"),
TextJustification.MIDDLE_CENTER);
ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f);
Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16);
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.moist"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getMoisture()), TextJustification.MIDDLE_LEFT);
y += th;
int tw = w - 8 - 12;
int w2 = 55;
int w3 = tw - 50;
int y = 0;
int th = 14;
int valueX = w2 + 4;
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.temp"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
AlleleHelper.toDisplay(treeSpecies.getTemperature()),
TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.ph"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getPH()), TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.moist"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
AlleleHelper.toDisplay(treeSpecies.getMoisture()),
TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.fertility"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.ph"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
AlleleHelper.toDisplay(treeSpecies.getPH()),
TextJustification.MIDDLE_LEFT);
y += th;
float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
String lifespanValue = String.format("%.2f", lifespan);
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.lifespan"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.fertility"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
genome.getFertility() + "x",
TextJustification.MIDDLE_LEFT);
y += th;
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise("botany.gui.database.tab.genome.nectar"), TextJustification.MIDDLE_RIGHT);
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFT);
y += th;
float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
String lifespanValue = String.format("%.2f", lifespan);
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.lifespan"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue),
TextJustification.MIDDLE_LEFT);
y += th;
int x = w2;
int tot = 0;
for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
if (vid.getGenome().getPrimary() == treeSpecies) {
if (tot > 0 && tot % 3 == 0) {
x -= 54;
y += 18;
}
ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER.ordinal());
ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
display.setItemStack(stack);
tot++;
x += 18;
}
}
new ControlText(
contents,
new IArea(0.0f, y, w2, th),
I18N.localise("botany.gui.database.tab.genome.nectar"),
TextJustification.MIDDLE_RIGHT);
new ControlText(
contents,
new IArea(valueX, y, w3, th),
genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(),
TextJustification.MIDDLE_LEFT);
y += th;
int numOfLines = 1 + (tot - 1) / 3;
new ControlText(contents, new IArea(0.0f, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise("botany.gui.database.tab.genome.varieties"), TextJustification.MIDDLE_RIGHT);
y += th;
contents.setSize(new IPoint(contents.size().x(), y));
scrollable.setScrollableContent(contents);
}
int x = w2;
int tot = 0;
for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
if (vid.getGenome().getPrimary() == treeSpecies) {
if (tot > 0 && tot % 3 == 0) {
x -= 54;
y += 18;
}
ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER.ordinal());
ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
display.setItemStack(stack);
tot++;
x += 18;
}
}
int numOfLines = 1 + (tot - 1) / 3;
new ControlText(
contents,
new IArea(0.0f, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines),
I18N.localise("botany.gui.database.tab.genome.varieties"),
TextJustification.MIDDLE_RIGHT);
y += th;
contents.setSize(new IPoint(contents.size().x(), y));
scrollable.setScrollableContent(contents);
}
}
@@ -1,5 +1,11 @@
package binnie.botany.craftgui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.IFlowerColor;
@@ -21,71 +27,72 @@ import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WindowBotanistDatabase extends WindowAbstractDatabase {
public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) {
super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f);
}
public static Window create(EntityPlayer player, Side side, boolean nei) {
return new WindowBotanistDatabase(player, side, nei);
}
public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) {
super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f);
}
@Override
protected void addTabs() {
new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.overview"));
new PageSpeciesFlowerGenome(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "genome"));
new PageSpeciesClassification(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.classification"));
new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.resultant"));
new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.further"));
new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview"));
new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.species"));
createMode(FlowerMode.COLOR, new ColorModeWidget());
new PageColorMixResultant(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.resultant"));
new PageColorMix(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.further"));
new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(Botany.instance, "breeder"));
}
public static Window create(EntityPlayer player, Side side, boolean nei) {
return new WindowBotanistDatabase(player, side, nei);
}
@Override
protected AbstractMod getMod() {
return Botany.instance;
}
@Override
protected void addTabs() {
new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.overview"));
new PageSpeciesFlowerGenome(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "genome"));
new PageSpeciesClassification(
getInfoPages(Mode.Species),
new DatabaseTab(Botany.instance, "species.classification"));
new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.resultant"));
new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.further"));
new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview"));
new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.species"));
createMode(FlowerMode.COLOR, new ColorModeWidget());
new PageColorMixResultant(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.resultant"));
new PageColorMix(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.further"));
new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(Botany.instance, "breeder"));
}
@Override
protected String getName() {
return I18N.localise("botany.gui.database.name");
}
@Override
protected AbstractMod getMod() {
return Botany.instance;
}
enum FlowerMode implements IDatabaseMode {
COLOR;
@Override
protected String getName() {
return I18N.localise("botany.gui.database.name");
}
@Override
public String getName() {
return I18N.localise("botany.gui.database.tab." + name().toLowerCase());
}
}
enum FlowerMode implements IDatabaseMode {
private class ColorModeWidget extends ModeWidgets {
public ColorModeWidget() {
super(FlowerMode.COLOR, WindowBotanistDatabase.this);
}
COLOR;
@Override
public void createListBox(IArea area) {
listBox = new ControlListBox<IFlowerColor>(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
@Override
public IWidget createOption(IFlowerColor value, int y) {
return new ControlColorOption(getContent(), value, y);
}
};
List<IFlowerColor> colors = new ArrayList<>();
Collections.addAll(colors, EnumFlowerColor.values());
listBox.setOptions(colors);
}
}
@Override
public String getName() {
return I18N.localise("botany.gui.database.tab." + name().toLowerCase());
}
}
private class ColorModeWidget extends ModeWidgets {
public ColorModeWidget() {
super(FlowerMode.COLOR, WindowBotanistDatabase.this);
}
@Override
public void createListBox(IArea area) {
listBox = new ControlListBox<IFlowerColor>(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
@Override
public IWidget createOption(IFlowerColor value, int y) {
return new ControlColorOption(getContent(), value, y);
}
};
List<IFlowerColor> colors = new ArrayList<>();
Collections.addAll(colors, EnumFlowerColor.VALUES);
listBox.setOptions(colors);
}
}
}
@@ -1,5 +1,8 @@
package binnie.botany.farm;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.core.circuits.BinnieCircuit;
@@ -7,101 +10,95 @@ import binnie.core.util.I18N;
import forestry.api.circuits.ChipsetManager;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
public class CircuitGarden extends BinnieCircuit {
private boolean isManual;
private boolean isFertilised;
private ItemStack icon;
private EnumMoisture moisture;
private EnumAcidity acidity;
public CircuitGarden(EnumMoisture moisture, EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) {
super("garden." + moisture.getID() + ((ph != null) ? ("." + ph.getID()) : "") + (manual ? ".manual" : "") + (fertilised ? ".fert" : ""), 4, manual ? ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual") : ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"), recipe);
this.moisture = moisture;
this.icon = icon;
isManual = manual;
isFertilised = fertilised;
acidity = ph;
String info = "";
private final boolean isManual;
private final boolean isFertilised;
private final ItemStack icon;
private final EnumMoisture moisture;
private final EnumAcidity acidity;
if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.moisture.dry")
+ EnumChatFormatting.RESET;
}
public CircuitGarden(EnumMoisture moisture, EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe,
ItemStack icon) {
super(
"garden." + moisture.getID()
+ ((ph != null) ? ("." + ph.getID()) : "")
+ (manual ? ".manual" : "")
+ (fertilised ? ".fert" : ""),
4,
manual ? ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual")
: ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"),
recipe);
this.moisture = moisture;
this.icon = icon;
isManual = manual;
isFertilised = fertilised;
acidity = ph;
String info = "";
if (moisture == EnumMoisture.DAMP) {
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.moisture.damp")
+ EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.dry") + EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ACID) {
if (info.length() > 0) {
info += ", ";
}
info += EnumChatFormatting.RED
+ I18N.localise("botany.ph.acid")
+ EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DAMP) {
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.damp") + EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.NEUTRAL) {
if (info.length() > 0) {
info += ", ";
}
info += EnumChatFormatting.GREEN
+ I18N.localise("botany.ph.neutral")
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ACID) {
if (!info.isEmpty()) {
info += ", ";
}
info += EnumChatFormatting.RED + I18N.localise("botany.ph.acid") + EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ALKALINE) {
if (info.length() > 0) {
info += ", ";
}
info += EnumChatFormatting.AQUA
+ I18N.localise("botany.ph.alkaline")
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.NEUTRAL) {
if (!info.isEmpty()) {
info += ", ";
}
info += EnumChatFormatting.GREEN + I18N.localise("botany.ph.neutral") + EnumChatFormatting.RESET;
}
if (info.length() > 0) {
info = " (" + info + EnumChatFormatting.RESET + ")";
}
addTooltipString(I18N.localise("botany.circuit.flowers") + info);
}
if (acidity == EnumAcidity.ALKALINE) {
if (!info.isEmpty()) {
info += ", ";
}
info += EnumChatFormatting.AQUA + I18N.localise("botany.ph.alkaline") + EnumChatFormatting.RESET;
}
@Override
public boolean isCircuitable(Object tile) {
return tile instanceof IFarmHousing;
}
if (!info.isEmpty()) {
info = " (" + info + EnumChatFormatting.RESET + ")";
}
addTooltipString(I18N.localise("botany.circuit.flowers") + info);
}
@Override
public void onInsertion(int slot, Object tile) {
if (!isCircuitable(tile)) {
return;
}
@Override
public boolean isCircuitable(Object tile) {
return tile instanceof IFarmHousing;
}
GardenLogic logic = new GardenLogic((IFarmHousing) tile);
logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName()));
((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic);
}
@Override
public void onInsertion(int slot, Object tile) {
if (!isCircuitable(tile)) {
return;
}
@Override
public void onLoad(int slot, Object tile) {
onInsertion(slot, tile);
}
GardenLogic logic = new GardenLogic((IFarmHousing) tile);
logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName()));
((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic);
}
@Override
public void onRemoval(int slot, Object tile) {
if (!isCircuitable(tile)) {
return;
}
((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]);
}
@Override
public void onLoad(int slot, Object tile) {
onInsertion(slot, tile);
}
@Override
public void onRemoval(int slot, Object tile) {
if (!isCircuitable(tile)) {
return;
}
((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]);
}
@Override
public void onTick(int arg0, Object arg1) {
// ignored
}
}
+41 -40
View File
@@ -1,58 +1,59 @@
package binnie.botany.farm;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmLogic;
import forestry.core.utils.vect.Vect;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmLogic;
import forestry.core.utils.vect.Vect;
public abstract class FarmLogic implements IFarmLogic {
protected World world;
protected IFarmHousing housing;
protected boolean isManual;
public FarmLogic(IFarmHousing housing) {
this.housing = housing;
}
protected World world;
protected IFarmHousing housing;
protected boolean isManual;
@Override
public IFarmLogic setManual(boolean flag) {
isManual = flag;
return this;
}
public FarmLogic(IFarmHousing housing) {
this.housing = housing;
}
protected boolean isAirBlock(Vect position) {
return world.isAirBlock(position.x, position.y, position.z);
}
@Override
public IFarmLogic setManual(boolean flag) {
isManual = flag;
return this;
}
protected boolean isWaterBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z) == Blocks.water;
}
protected boolean isAirBlock(Vect position) {
return world.isAirBlock(position.x, position.y, position.z);
}
protected Block getBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z);
}
protected boolean isWaterBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z) == Blocks.water;
}
protected int getBlockMeta(Vect position) {
return world.getBlockMetadata(position.x, position.y, position.z);
}
protected Block getBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z);
}
protected ItemStack getAsItemStack(Vect position) {
return new ItemStack(getBlock(position), 1, getBlockMeta(position));
}
protected int getBlockMeta(Vect position) {
return world.getBlockMetadata(position.x, position.y, position.z);
}
protected Vect translateWithOffset(int x, int y, int z, FarmDirection direction, int step) {
return new Vect(
x + direction.getForgeDirection().offsetX * step,
y + direction.getForgeDirection().offsetY * step,
z + direction.getForgeDirection().offsetZ * step
);
}
protected ItemStack getAsItemStack(Vect position) {
return new ItemStack(getBlock(position), 1, getBlockMeta(position));
}
protected void setBlock(Vect position, Block block, int meta) {
world.setBlock(position.x, position.y, position.z, block, meta, 2);
}
protected Vect translateWithOffset(int x, int y, int z, FarmDirection direction, int step) {
return new Vect(
x + direction.getForgeDirection().offsetX * step,
y + direction.getForgeDirection().offsetY * step,
z + direction.getForgeDirection().offsetZ * step);
}
protected void setBlock(Vect position, Block block, int meta) {
world.setBlock(position.x, position.y, position.z, block, meta, 2);
}
}
@@ -1,5 +1,9 @@
package binnie.botany.farm;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlower;
@@ -7,36 +11,34 @@ import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class FarmableFlower implements IFarmable {
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == Botany.flower;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
return null;
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == Botany.flower;
}
@Override
public boolean isGermling(ItemStack itemstack) {
EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack);
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
return null;
}
@Override
public boolean isWindfall(ItemStack itemstack) {
return false;
}
@Override
public boolean isGermling(ItemStack itemstack) {
EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack);
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(germling);
Gardening.plant(world, x, y, z, flower, player.getGameProfile());
return true;
}
@Override
public boolean isWindfall(ItemStack itemstack) {
return false;
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(germling);
Gardening.plant(world, x, y, z, flower, player.getGameProfile());
return true;
}
}
@@ -1,21 +1,23 @@
package binnie.botany.farm;
import binnie.botany.api.IFlower;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class FarmableVanillaFlower extends FarmableFlower {
@Override
public boolean isGermling(ItemStack itemstack) {
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
}
import binnie.botany.api.IFlower;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getConversion(germling);
return Gardening.plant(world, x, y, z, flower, player.getGameProfile());
}
public class FarmableVanillaFlower extends FarmableFlower {
@Override
public boolean isGermling(ItemStack itemstack) {
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getConversion(germling);
return Gardening.plant(world, x, y, z, flower, player.getGameProfile());
}
}
+338 -344
View File
@@ -1,22 +1,9 @@
package binnie.botany.farm;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.gardening.Gardening;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.core.access.IOwnable;
import forestry.core.utils.vect.Vect;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
@@ -28,380 +15,387 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.mojang.authlib.GameProfile;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.gardening.Gardening;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.core.access.IOwnable;
import forestry.core.utils.vect.Vect;
public class GardenLogic extends FarmLogic {
protected EnumMoisture moisture;
protected EnumAcidity acidity;
protected boolean fertilised;
protected String name;
protected ArrayList<ItemStack> produce;
protected List<IFarmable> farmables;
private ItemStack icon;
protected EnumMoisture moisture;
protected EnumAcidity acidity;
protected boolean fertilised;
protected String name;
protected ArrayList<ItemStack> produce;
protected List<IFarmable> farmables;
public GardenLogic(IFarmHousing housing) {
super(housing);
produce = new ArrayList<>();
farmables = new ArrayList<>();
farmables.add(new FarmableFlower());
farmables.add(new FarmableVanillaFlower());
}
private ItemStack icon;
@Override
public int getFertilizerConsumption() {
return fertilised ? 8 : 2;
}
public GardenLogic(IFarmHousing housing) {
super(housing);
produce = new ArrayList<>();
farmables = new ArrayList<>();
farmables.add(new FarmableFlower());
farmables.add(new FarmableVanillaFlower());
}
@Override
public int getWaterConsumption(float hydrationModifier) {
return (int) (moisture.ordinal() * 40 * hydrationModifier);
}
@Override
public int getFertilizerConsumption() {
return fertilised ? 8 : 2;
}
@Override
public boolean isAcceptedResource(ItemStack stack) {
Item item = stack.getItem();
return Gardening.isSoil(item)
|| item == Item.getItemFromBlock(Blocks.sand)
|| item == Item.getItemFromBlock(Blocks.dirt)
|| Gardening.isAcidFertiliser(stack)
|| Gardening.isAlkalineFertiliser(stack);
}
@Override
public int getWaterConsumption(float hydrationModifier) {
return (int) (moisture.ordinal() * 40 * hydrationModifier);
}
@Override
public Collection<ItemStack> collect() {
Collection<ItemStack> products = produce;
produce = new ArrayList<>();
return products;
}
@Override
public boolean isAcceptedResource(ItemStack stack) {
Item item = stack.getItem();
return Gardening.isSoil(item) || item == Item.getItemFromBlock(Blocks.sand)
|| item == Item.getItemFromBlock(Blocks.dirt)
|| Gardening.isAcidFertiliser(stack)
|| Gardening.isAlkalineFertiliser(stack);
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
world = housing.getWorld();
return maintainSoil(x, y, z, direction, extent)
|| !isManual && maintainWater(x, y, z, direction, extent)
|| maintainCrops(x, y + 1, z, direction, extent);
}
@Override
public Collection<ItemStack> collect() {
Collection<ItemStack> products = produce;
produce = new ArrayList<>();
return products;
}
private boolean isWaste(ItemStack stack) {
return stack.getItem() == Item.getItemFromBlock(Blocks.dirt);
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
world = housing.getWorld();
return maintainSoil(x, y, z, direction, extent) || !isManual && maintainWater(x, y, z, direction, extent)
|| maintainCrops(x, y + 1, z, direction, extent);
}
private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
boolean isSoil = Gardening.isSoil(world.getBlock(position.x, position.y, position.z));
// remove unnecessary blocks
if (!isManual && !isSoil && !isAirBlock(position)) {
Block block = world.getBlock(position.x, position.y, position.z);
if (moisture == EnumMoisture.DAMP) {
if (block != Blocks.water) {
dropBlockAsProduction(position);
}
} else if (moisture == EnumMoisture.DRY) {
if (block != Blocks.sand) {
dropBlockAsProduction(position);
}
} else {
dropBlockAsProduction(position);
}
}
private boolean isWaste(ItemStack stack) {
return stack.getItem() == Item.getItemFromBlock(Blocks.dirt);
}
if (fertilised && isSoil) {
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) {
continue;
}
}
private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
boolean isSoil = Gardening.isSoil(world.getBlock(position.x, position.y, position.z));
if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) {
world.setBlockToAir(position.x, position.y + 1, position.z);
continue;
}
// remove unnecessary blocks
if (!isManual && !isSoil && !isAirBlock(position)) {
Block block = world.getBlock(position.x, position.y, position.z);
if (moisture == EnumMoisture.DAMP) {
if (block != Blocks.water) {
dropBlockAsProduction(position);
}
} else if (moisture == EnumMoisture.DRY) {
if (block != Blocks.sand) {
dropBlockAsProduction(position);
}
} else {
dropBlockAsProduction(position);
}
}
if (acidity != null && isSoil) {
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z);
if (pH.ordinal() < acidity.ordinal()) {
ItemStack stack = getAvailableAlkaline();
if (stack != null && soil.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() + 1])) {
housing.getFarmInventory().removeResources(new ItemStack[]{stack});
continue;
}
}
if (fertilised && isSoil) {
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) {
continue;
}
}
if (pH.ordinal() > acidity.ordinal()) {
ItemStack stack = getAvailableAcid();
if (stack != null && soil.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() - 1])) {
housing.getFarmInventory().removeResources(new ItemStack[]{stack});
continue;
}
}
}
if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) {
world.setBlockToAir(position.x, position.y + 1, position.z);
continue;
}
if (!isAirBlock(position) && !world.getBlock(position.x, position.y, position.z).isReplaceable(world, position.x, position.y, position.z)) {
ItemStack block = getAsItemStack(position);
ItemStack loam = getAvailableLoam();
if (isWaste(block) && loam != null) {
produce.addAll(Blocks.dirt.getDrops(world, position.x, position.y, position.z, block.getItemDamage(), 0));
setBlock(position, Blocks.air, 0);
return trySetSoil(position, loam);
}
} else if (!isManual) {
if (!isWaterBlock(position)) {
if (i % 2 == 0) {
return trySetSoil(position);
}
if (acidity != null && isSoil) {
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z);
if (pH.ordinal() < acidity.ordinal()) {
ItemStack stack = getAvailableAlkaline();
if (stack != null && soil
.setPH(world, position.x, position.y, position.z, EnumAcidity.VALUES[pH.ordinal() + 1])) {
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
continue;
}
}
FarmDirection cclock = FarmDirection.EAST;
if (direction == FarmDirection.EAST) {
cclock = FarmDirection.SOUTH;
} else if (direction == FarmDirection.SOUTH) {
cclock = FarmDirection.EAST;
} else if (direction == FarmDirection.WEST) {
cclock = FarmDirection.SOUTH;
}
if (pH.ordinal() > acidity.ordinal()) {
ItemStack stack = getAvailableAcid();
if (stack != null && soil
.setPH(world, position.x, position.y, position.z, EnumAcidity.VALUES[pH.ordinal() - 1])) {
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
continue;
}
}
}
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
ItemStack soil2 = getAsItemStack(previous);
if (!Gardening.isSoil(soil2.getItem())) {
trySetSoil(position);
}
}
}
}
return false;
}
if (!isAirBlock(position) && !world.getBlock(position.x, position.y, position.z)
.isReplaceable(world, position.x, position.y, position.z)) {
ItemStack block = getAsItemStack(position);
ItemStack loam = getAvailableLoam();
if (isWaste(block) && loam != null) {
produce.addAll(
Blocks.dirt.getDrops(world, position.x, position.y, position.z, block.getItemDamage(), 0));
setBlock(position, Blocks.air, 0);
return trySetSoil(position, loam);
}
} else if (!isManual) {
if (!isWaterBlock(position)) {
if (i % 2 == 0) {
return trySetSoil(position);
}
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (!isAirBlock(position) && !world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
continue;
}
FarmDirection cclock = FarmDirection.EAST;
if (direction == FarmDirection.EAST) {
cclock = FarmDirection.SOUTH;
} else if (direction == FarmDirection.SOUTH) {
cclock = FarmDirection.EAST;
} else if (direction == FarmDirection.WEST) {
cclock = FarmDirection.SOUTH;
}
if (isWaterBlock(position)) {
continue;
}
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
ItemStack soil2 = getAsItemStack(previous);
if (!Gardening.isSoil(soil2.getItem())) {
trySetSoil(position);
}
}
}
}
return false;
}
boolean isEnclosed = true;
if (world.isAirBlock(position.x + 1, position.y, position.z)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x - 1, position.y, position.z)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x, position.y, position.z + 1)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x, position.y, position.z - 1)) {
isEnclosed = false;
}
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (!isAirBlock(position)
&& !world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
continue;
}
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
if (isEnclosed) {
return trySetWater(position);
}
}
return false;
}
if (isWaterBlock(position)) {
continue;
}
private ItemStack getAvailableLoam() {
EnumMoisture[] moistures;
if (moisture == EnumMoisture.DAMP) {
moistures = new EnumMoisture[]{
EnumMoisture.DAMP,
EnumMoisture.NORMAL,
EnumMoisture.DRY
};
} else if (moisture == EnumMoisture.DRY) {
moistures = new EnumMoisture[]{
EnumMoisture.DRY,
EnumMoisture.DAMP,
EnumMoisture.DRY
};
} else {
moistures = new EnumMoisture[]{
EnumMoisture.DRY,
EnumMoisture.NORMAL,
EnumMoisture.DAMP
};
}
boolean isEnclosed = true;
if (world.isAirBlock(position.x + 1, position.y, position.z)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x - 1, position.y, position.z)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x, position.y, position.z + 1)) {
isEnclosed = false;
} else if (world.isAirBlock(position.x, position.y, position.z - 1)) {
isEnclosed = false;
}
EnumAcidity[] acidities = {
EnumAcidity.NEUTRAL,
EnumAcidity.ACID,
EnumAcidity.ALKALINE
};
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
if (isEnclosed) {
return trySetWater(position);
}
}
return false;
}
for (EnumMoisture moist : moistures) {
for (EnumAcidity acid : acidities) {
for (Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) {
int meta = acid.ordinal() * 3 + moist.ordinal();
ItemStack[] resource = {new ItemStack(type, 1, meta)};
if (housing.getFarmInventory().hasResources(resource)) {
return resource[0];
}
}
}
}
private ItemStack getAvailableLoam() {
EnumMoisture[] moistures;
if (moisture == EnumMoisture.DAMP) {
moistures = new EnumMoisture[] { EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY };
} else if (moisture == EnumMoisture.DRY) {
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY };
} else {
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP };
}
if (housing.getFarmInventory().hasResources(new ItemStack[]{new ItemStack(Blocks.dirt)})) {
return new ItemStack(Blocks.dirt);
}
return null;
}
EnumAcidity[] acidities = { EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE };
private boolean trySetSoil(Vect position) {
return trySetSoil(position, getAvailableLoam());
}
for (EnumMoisture moist : moistures) {
for (EnumAcidity acid : acidities) {
for (Block type : new Block[] { Botany.flowerbed, Botany.loam, Botany.soil }) {
int meta = acid.ordinal() * 3 + moist.ordinal();
ItemStack[] resource = { new ItemStack(type, 1, meta) };
if (housing.getFarmInventory().hasResources(resource)) {
return resource[0];
}
}
}
}
private boolean trySetSoil(Vect position, ItemStack loam) {
ItemStack copy = loam;
if (loam == null) {
return false;
}
if (housing.getFarmInventory().hasResources(new ItemStack[] { new ItemStack(Blocks.dirt) })) {
return new ItemStack(Blocks.dirt);
}
return null;
}
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
loam = new ItemStack(Botany.soil, 0, 4);
}
private boolean trySetSoil(Vect position) {
return trySetSoil(position, getAvailableLoam());
}
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
housing.getFarmInventory().removeResources(new ItemStack[]{copy});
return true;
}
private boolean trySetSoil(Vect position, ItemStack loam) {
ItemStack copy = loam;
if (loam == null) {
return false;
}
private boolean trySetWater(Vect position) {
FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
if (moisture == EnumMoisture.DAMP) {
if (!housing.hasLiquid(water)) {
return false;
}
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
loam = new ItemStack(Botany.soil, 0, 4);
}
setBlock(position, Blocks.water, 0);
housing.removeLiquid(water);
return true;
}
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
housing.getFarmInventory().removeResources(new ItemStack[] { copy });
return true;
}
if (moisture != EnumMoisture.DRY) {
return trySetSoil(position);
}
private boolean trySetWater(Vect position) {
FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
if (moisture == EnumMoisture.DAMP) {
if (!housing.hasLiquid(water)) {
return false;
}
ItemStack[] sand = {new ItemStack(Blocks.sand, 1)};
if (!housing.getFarmInventory().hasResources(sand)) {
return false;
}
setBlock(position, Blocks.water, 0);
housing.removeLiquid(water);
return true;
}
setBlock(position, Blocks.sand, 0);
housing.getFarmInventory().removeResources(sand);
return true;
}
if (moisture != EnumMoisture.DRY) {
return trySetSoil(position);
}
private void dropBlockAsProduction(Vect position) {
ItemStack stack = new ItemStack(world.getBlock(position.x, position.y, position.z));
if (stack.getItem() == null) {
return;
}
produce.add(stack);
world.setBlockToAir(position.x, position.y, position.z);
}
ItemStack[] sand = { new ItemStack(Blocks.sand, 1) };
if (!housing.getFarmInventory().hasResources(sand)) {
return false;
}
@Override
public boolean isAcceptedGermling(ItemStack stack) {
for (IFarmable farmable : farmables) {
if (farmable.isGermling(stack)) {
return true;
}
}
return false;
}
setBlock(position, Blocks.sand, 0);
housing.getFarmInventory().removeResources(sand);
return true;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
return null;
}
private void dropBlockAsProduction(Vect position) {
ItemStack stack = new ItemStack(world.getBlock(position.x, position.y, position.z));
if (stack.getItem() == null) {
return;
}
produce.add(stack);
world.setBlockToAir(position.x, position.y, position.z);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return icon.getIconIndex();
}
@Override
public boolean isAcceptedGermling(ItemStack stack) {
for (IFarmable farmable : farmables) {
if (farmable.isGermling(stack)) {
return true;
}
}
return false;
}
public void setIcon(ItemStack icon) {
this.icon = icon;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
return null;
}
@Override
public ResourceLocation getSpriteSheet() {
return TextureMap.locationBlocksTexture;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return icon.getIconIndex();
}
@Override
public String getName() {
return name;
}
public void setIcon(ItemStack icon) {
this.icon = icon;
}
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (isAirBlock(position) || world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
if (Gardening.isSoil(below.getItem())) {
return trySetCrop(position);
}
}
}
return false;
}
@Override
public ResourceLocation getSpriteSheet() {
return TextureMap.locationBlocksTexture;
}
private boolean trySetCrop(Vect position) {
for (IFarmable farmable : farmables) {
boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z);
if (!success || !(housing instanceof IOwnable)) {
continue;
}
@Override
public String getName() {
return name;
}
TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z);
if (!(tile instanceof TileEntityFlower)) {
return true;
}
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (isAirBlock(position)
|| world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
if (Gardening.isSoil(below.getItem())) {
return trySetCrop(position);
}
}
}
return false;
}
try {
IOwnable housing2 = (IOwnable) housing;
GameProfile prof = (GameProfile) IOwnable.class.getMethod("getOwnerProfile", new Class[0]).invoke(housing2);
((TileEntityFlower) tile).setOwner(prof);
} catch (Exception ex) {
// ignored
}
return true;
}
return false;
}
private boolean trySetCrop(Vect position) {
for (IFarmable farmable : farmables) {
boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z);
if (!success || !(housing instanceof IOwnable)) {
continue;
}
public ItemStack getAvailableAcid() {
for (ItemStack stack : Gardening.getAcidFertilisers()) {
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) {
return stack;
}
}
return null;
}
TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z);
if (!(tile instanceof TileEntityFlower)) {
return true;
}
public ItemStack getAvailableAlkaline() {
for (ItemStack stack : Gardening.getAlkalineFertilisers()) {
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) {
return stack;
}
}
return null;
}
try {
IOwnable housing2 = (IOwnable) housing;
GameProfile prof = (GameProfile) IOwnable.class.getMethod("getOwnerProfile").invoke(housing2);
((TileEntityFlower) tile).setOwner(prof);
} catch (Exception ex) {
// ignored
}
return true;
}
return false;
}
public void setData(EnumMoisture moisture, EnumAcidity acidity, boolean isManual, boolean fertilised, ItemStack icon, String name) {
this.moisture = moisture;
this.acidity = acidity;
this.isManual = isManual;
this.fertilised = fertilised;
this.icon = icon;
this.name = name;
}
public ItemStack getAvailableAcid() {
for (ItemStack stack : Gardening.getAcidFertilisers()) {
if (stack != null && stack.getItem() != null
&& housing.getFarmInventory().hasResources(new ItemStack[] { stack })) {
return stack;
}
}
return null;
}
public ItemStack getAvailableAlkaline() {
for (ItemStack stack : Gardening.getAlkalineFertilisers()) {
if (stack != null && stack.getItem() != null
&& housing.getFarmInventory().hasResources(new ItemStack[] { stack })) {
return stack;
}
}
return null;
}
public void setData(EnumMoisture moisture, EnumAcidity acidity, boolean isManual, boolean fertilised,
ItemStack icon, String name) {
this.moisture = moisture;
this.acidity = acidity;
this.isManual = isManual;
this.fertilised = fertilised;
this.icon = icon;
this.name = name;
}
}
@@ -1,16 +1,9 @@
package binnie.botany.flower;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
import binnie.botany.genetics.EnumFlowerType;
import binnie.core.BinnieCore;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -25,208 +18,209 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.mojang.authlib.GameProfile;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
import binnie.botany.genetics.EnumFlowerType;
import binnie.core.BinnieCore;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFlower extends BlockContainer {
public BlockFlower() {
super(Material.plants);
float f = 0.2f;
setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, f * 3.0f, 0.5f + f);
setTickRandomly(true);
setBlockName("flower");
setStepSound(Block.soundTypeGrass);
}
@Override
public String getUnlocalizedName() {
return "botany.flower";
}
public BlockFlower() {
super(Material.plants);
float f = 0.2f;
setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, f * 3.0f, 0.5f + f);
setTickRandomly(true);
setBlockName("flower");
setStepSound(Block.soundTypeGrass);
}
@Override
public int getRenderType() {
return RendererBotany.renderID;
}
@Override
public String getUnlocalizedName() {
return "botany.flower";
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumFlowerType type : EnumFlowerType.values()) {
type.registerIcons(register);
}
}
@Override
public int getRenderType() {
return RendererBotany.renderID;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFlower();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumFlowerType type : EnumFlowerType.VALUES) {
type.registerIcons(register);
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFlower();
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack);
TileEntity flower = world.getTileEntity(x, y, z);
if (!BinnieCore.proxy.isSimulating(world)) {
if (flower != null && flower instanceof TileEntityFlower) {
IFlower f = BotanyCore.getFlowerRoot().getMember(stack);
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
}
return;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
TileEntity below = world.getTileEntity(x, y - 1, z);
if (flower != null && flower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) {
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
} else {
GameProfile owner = (entity instanceof EntityPlayer) ? ((EntityPlayer) entity).getGameProfile() : null;
((TileEntityFlower) flower).create(stack, owner);
}
}
Gardening.tryGrowSection(world, x, y, z);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack);
TileEntity flower = world.getTileEntity(x, y, z);
if (!BinnieCore.proxy.isSimulating(world)) {
if (flower instanceof TileEntityFlower) {
IFlower f = BotanyCore.getFlowerRoot().getMember(stack);
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
}
return;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower)) {
return super.getIcon(world, x, y, z, side);
}
TileEntity below = world.getTileEntity(x, y - 1, z);
if (flower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) {
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
} else {
GameProfile owner = (entity instanceof EntityPlayer) ? ((EntityPlayer) entity).getGameProfile() : null;
((TileEntityFlower) flower).create(stack, owner);
}
}
Gardening.tryGrowSection(world, x, y, z);
}
TileEntityFlower f = (TileEntityFlower) tile;
EnumFlowerStage stage = (f.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
IFlowerType flower = f.getType();
int section = f.getRenderSection();
boolean flowered = f.isFlowered();
if (RendererBotany.pass == 0) {
return flower.getStem(stage, flowered, section);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower tileFlower)) {
return super.getIcon(world, x, y, z, side);
}
return (RendererBotany.pass == 1) ?
flower.getPetalIcon(stage, flowered, section) :
flower.getVariantIcon(stage, flowered, section);
}
EnumFlowerStage stage = (tileFlower.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
IFlowerType flower = tileFlower.getType();
int section = tileFlower.getRenderSection();
boolean flowered = tileFlower.isFlowered();
if (RendererBotany.pass == 0) {
return flower.getStem(stage, flowered, section);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) {
TileEntityFlower f = (TileEntityFlower) tile;
if (RendererBotany.pass == 0) {
return f.getStemColour();
}
return (RendererBotany.pass == 1) ?
f.getPrimaryColor() :
f.getSecondaryColor();
}
return 0xffffff;
}
return (RendererBotany.pass == 1) ? flower.getPetalIcon(stage, flowered, section)
: flower.getVariantIcon(stage, flowered, section);
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return super.canPlaceBlockAt(world, x, y, z)
&& canBlockStay(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower tileFlower) {
if (RendererBotany.pass == 0) {
return tileFlower.getStemColour();
}
return (RendererBotany.pass == 1) ? tileFlower.getPrimaryColor() : tileFlower.getSecondaryColor();
}
return 0xffffff;
}
protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.grass
|| block == Blocks.dirt
|| block == Blocks.farmland
|| Gardening.isSoil(block);
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return super.canPlaceBlockAt(world, x, y, z) && canBlockStay(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
checkAndDropBlock(world, x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower)) {
return;
}
protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.grass || block == Blocks.dirt || block == Blocks.farmland || Gardening.isSoil(block);
}
TileEntityFlower flower = (TileEntityFlower) tile;
if (flower.getSection() == 0
&& flower.getFlower() != null
&& flower.getFlower().getAge() > 0
&& flower.getFlower().getGenome().getPrimary().getType().getSections() > 1
&& world.getBlock(x, y + 1, z) != Botany.flower) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
checkAndDropBlock(world, x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower tileFlower)) {
return;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand);
checkAndDropBlock(world, x, y, z);
return;
}
world.setBlockToAir(x, y, z);
}
if (tileFlower.getSection() == 0 && tileFlower.getFlower() != null
&& tileFlower.getFlower().getAge() > 0
&& tileFlower.getFlower().getGenome().getPrimary().getType().getSections() > 1
&& world.getBlock(x, y + 1, z) != Botany.flower) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!canBlockStay(world, x, y, z)) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand);
checkAndDropBlock(world, x, y, z);
return;
}
world.setBlockToAir(x, y, z);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return world.getBlock(x, y - 1, z) == Botany.flower;
}
return canPlaceBlockOn(world.getBlock(x, y - 1, z));
}
protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!canBlockStay(world, x, y, z)) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (flower != null) {
drops.add(flower);
}
}
return drops;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return world.getBlock(x, y - 1, z) == Botany.flower;
}
return canPlaceBlockOn(world.getBlock(x, y - 1, z));
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
List<ItemStack> drops = getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
boolean hasBeenBroken = world.setBlockToAir(x, y, z);
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
dropBlockAsItem(world, x, y, z, drop);
}
}
return hasBeenBroken;
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (flower != null) {
drops.add(flower);
}
}
return drops;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) {
return Blocks.yellow_flower.getIcon(0, 0);
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
List<ItemStack> drops = getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
boolean hasBeenBroken = world.setBlockToAir(x, y, z);
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world)
&& !drops.isEmpty()
&& (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
dropBlockAsItem(world, x, y, z, drop);
}
}
return hasBeenBroken;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) {
return Blocks.yellow_flower.getIcon(0, 0);
}
}
+250 -235
View File
@@ -1,5 +1,21 @@
package binnie.botany.flower;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
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;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
@@ -18,272 +34,271 @@ import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Config;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
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;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
public abstract class ItemBotany extends Item {
public ItemBotany(String name) {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName(name);
hasSubtypes = true;
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
public ItemBotany(String name) {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName(name);
hasSubtypes = true;
@Override
public boolean isDamageable() {
return false;
}
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
public boolean isRepairable() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
@Override
public boolean getShareTag() {
return true;
}
@Override
public boolean isDamageable() {
return false;
}
@Override
public boolean hasEffect(ItemStack stack, int pass) {
if (!stack.hasTagCompound()) {
return false;
}
@Override
public boolean isRepairable() {
return false;
}
IIndividual individual = getIndividual(stack);
return individual != null
&& individual.getGenome() != null
&& individual.hasEffect();
}
@Override
public boolean hasEffect(ItemStack stack, int pass) {
if (!stack.hasTagCompound()) {
return false;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List tooltip, boolean flag) {
if (!itemstack.hasTagCompound()) {
return;
}
IFlower individual = (IFlower) getIndividual(itemstack);
if (individual == null) {
tooltip.add(I18N.localise("botany.item.tooltip.bugged"));
return;
}
IIndividual individual = getIndividual(stack);
return individual != null && individual.getGenome() != null && individual.hasEffect();
}
IFlowerGenome genome = individual.getGenome();
IFlowerColor primaryColor = genome.getPrimaryColor();
IFlowerColor secondColor = genome.getSecondaryColor();
IFlowerColor stemColor = genome.getStemColor();
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> tooltip, boolean flag) {
if (!itemstack.hasTagCompound()) {
return;
}
IFlower individual = (IFlower) getIndividual(itemstack);
if (individual == null) {
tooltip.add(I18N.localise("botany.item.tooltip.bugged"));
return;
}
if (primaryColor == secondColor) {
tooltip.add(EnumChatFormatting.YELLOW + I18N.localise("botany.item.tooltip.flowerColor1", primaryColor.getName(), stemColor.getName()));
} else {
tooltip.add(EnumChatFormatting.YELLOW + I18N.localise("botany.item.tooltip.flowerColor2", primaryColor.getName(), secondColor.getName(), stemColor.getName()));
}
IFlowerGenome genome = individual.getGenome();
IFlowerColor primaryColor = genome.getPrimaryColor();
IFlowerColor secondColor = genome.getSecondaryColor();
IFlowerColor stemColor = genome.getStemColor();
if (individual.isAnalyzed()) {
if (BinnieCore.proxy.isShiftDown()) {
individual.addTooltip(tooltip);
} else {
tooltip.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.holdMore"));
}
} else {
tooltip.add(I18N.localise("botany.item.tooltip.unknownGenome"));
}
}
if (primaryColor == secondColor) {
tooltip.add(
EnumChatFormatting.YELLOW + I18N
.localise("botany.item.tooltip.flowerColor1", primaryColor.getName(), stemColor.getName()));
} else {
tooltip.add(
EnumChatFormatting.YELLOW + I18N.localise(
"botany.item.tooltip.flowerColor2",
primaryColor.getName(),
secondColor.getName(),
stemColor.getName()));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
}
if (individual.isAnalyzed()) {
if (BinnieCore.proxy.isShiftDown()) {
individual.addTooltip(tooltip);
} else {
tooltip.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.holdMore"));
}
} else {
tooltip.add(I18N.localise("botany.item.tooltip.unknownGenome"));
}
}
protected IIndividual getIndividual(ItemStack itemstack) {
return new Flower(itemstack.getTagCompound());
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (!itemstack.hasTagCompound()) {
return I18N.localise("botany.item.tooltip.unknown");
}
protected IIndividual getIndividual(ItemStack itemstack) {
return new Flower(itemstack.getTagCompound());
}
IIndividual individual = getIndividual(itemstack);
if (individual != null && individual.getGenome() != null) {
String tag = getTag();
if (tag == null || tag.isEmpty()) {
return individual.getDisplayName();
}
return I18N.localise("botany.item.botany.name", individual.getDisplayName(), tag);
}
return I18N.localise("botany.item.flowerCorrupted.name");
}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (!itemstack.hasTagCompound()) {
return I18N.localise("botany.item.tooltip.unknown");
}
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
addCreativeItems(itemList, true);
}
IIndividual individual = getIndividual(itemstack);
if (individual != null && individual.getGenome() != null) {
String tag = getTag();
if (tag == null || tag.isEmpty()) {
return individual.getDisplayName();
}
return I18N.localise("botany.item.botany.name", individual.getDisplayName(), tag);
}
return I18N.localise("botany.item.flowerCorrupted.name");
}
public void addCreativeItems(List itemList, boolean hideSecrets) {
for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) {
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
itemList.add(BotanyCore.speciesRoot.getMemberStack(individual.copy(), getStage().ordinal()));
}
}
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> itemList) {
addCreativeItems(itemList, true);
}
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null) {
return 0xffffff;
}
public void addCreativeItems(List<ItemStack> itemList, boolean hideSecrets) {
for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) {
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
itemList.add(BotanyCore.speciesRoot.getMemberStack(individual.copy(), getStage().ordinal()));
}
}
if (renderPass == 0) {
return flower.getGenome().getStemColor().getColor(flower.isWilted());
}
return (renderPass == 1) ?
flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) :
flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
}
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null) {
return 0xffffff;
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
if (renderPass == 0) {
return flower.getGenome().getStemColor().getColor(flower.isWilted());
}
return (renderPass == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
: flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
}
@Override
public int getRenderPasses(int metadata) {
return 3;
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return EnumFlowerType.ALLIUM.getBlank();
}
@Override
public int getRenderPasses(int metadata) {
return 3;
}
IFlowerType type = flower.getGenome().getPrimary().getType();
if (renderPass == 0) {
return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
if (renderPass == 1) {
return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return EnumFlowerType.ALLIUM.getBlank();
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
if (getStage() == EnumFlowerStage.POLLEN) {
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(itemstack);
TileEntity target = world.getTileEntity(x, y, z);
if (!(target instanceof IPollinatable)) {
return false;
}
IPollinatable pollinatable = (IPollinatable) target;
if (!pollinatable.canMateWith(flower)) {
return false;
}
pollinatable.mateWith(flower);
if (!player.capabilities.isCreativeMode) {
itemstack.stackSize--;
}
return true;
}
IFlowerType type = flower.getGenome().getPrimary().getType();
if (renderPass == 0) {
return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
if (renderPass == 1) {
return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
Block blockFlower = Botany.flower;
Block blockAlreadyThere = world.getBlock(x, y, z);
if (blockAlreadyThere == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 0x7) < 1) {
side = 1;
} else if (blockAlreadyThere != Blocks.vine && blockAlreadyThere != Blocks.tallgrass && blockAlreadyThere != Blocks.deadbush && !blockAlreadyThere.isReplaceable(world, x, y, z)) {
if (side == 0) {
y--;
} else if (side == 1) {
y++;
} else if (side == 2) {
z--;
} else if (side == 3) {
z++;
} else if (side == 4) {
x--;
} else if (side == 5) {
x++;
}
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side,
float px, float py, float pz) {
if (getStage() == EnumFlowerStage.POLLEN) {
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(itemstack);
TileEntity target = world.getTileEntity(x, y, z);
if (!(target instanceof IPollinatable pollinatable)) {
return false;
}
if (!pollinatable.canMateWith(flower)) {
return false;
}
pollinatable.mateWith(flower);
if (!player.capabilities.isCreativeMode) {
itemstack.stackSize--;
}
return true;
}
if (itemstack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, itemstack)) {
return false;
}
if (y == 255 && blockFlower.getMaterial().isSolid()) {
return false;
}
Block blockFlower = Botany.flower;
Block blockAlreadyThere = world.getBlock(x, y, z);
if (blockAlreadyThere == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 0x7) < 1) {
side = 1;
} else if (blockAlreadyThere != Blocks.vine && blockAlreadyThere != Blocks.tallgrass
&& blockAlreadyThere != Blocks.deadbush
&& !blockAlreadyThere.isReplaceable(world, x, y, z)) {
if (side == 0) {
y--;
} else if (side == 1) {
y++;
} else if (side == 2) {
z--;
} else if (side == 3) {
z++;
} else if (side == 4) {
x--;
} else if (side == 5) {
x++;
}
}
if (world.canPlaceEntityOnSide(blockFlower, x, y, z, false, side, player, itemstack)) {
int i1 = getMetadata(itemstack.getItemDamage());
int j1 = blockFlower.onBlockPlaced(world, x, y, z, side, px, py, pz, i1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, px, py, pz, j1)) {
world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, blockFlower.stepSound.func_150496_b(), (blockFlower.stepSound.getVolume() + 1.0f) / 2.0f, blockFlower.stepSound.getPitch() * 0.8f);
itemstack.stackSize--;
}
return true;
}
return false;
}
if (itemstack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, itemstack)) {
return false;
}
if (y == 255 && blockFlower.getMaterial().isSolid()) {
return false;
}
@SideOnly(Side.CLIENT)
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
Block field_150939_a = Botany.flower;
Block block = world.getBlock(x, y, z);
if (block == Blocks.snow_layer) {
side = 1;
} else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z)) {
if (side == 0) {
y--;
} else if (side == 1) {
y++;
} else if (side == 2) {
z--;
} else if (side == 3) {
z++;
} else if (side == 4) {
x--;
} else if (side == 5) {
x++;
}
}
return world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack);
}
if (world.canPlaceEntityOnSide(blockFlower, x, y, z, false, side, player, itemstack)) {
int i1 = getMetadata(itemstack.getItemDamage());
int j1 = blockFlower.onBlockPlaced(world, x, y, z, side, px, py, pz, i1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, px, py, pz, j1)) {
world.playSoundEffect(
x + 0.5f,
y + 0.5f,
z + 0.5f,
blockFlower.stepSound.func_150496_b(),
(blockFlower.stepSound.getVolume() + 1.0f) / 2.0f,
blockFlower.stepSound.getPitch() * 0.8f);
itemstack.stackSize--;
}
return true;
}
return false;
}
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
Block block = Botany.flower;
if (!world.setBlock(x, y, z, block, metadata, 3)) {
return false;
}
@SideOnly(Side.CLIENT)
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
Block field_150939_a = Botany.flower;
Block block = world.getBlock(x, y, z);
if (block == Blocks.snow_layer) {
side = 1;
} else if (block != Blocks.vine && block != Blocks.tallgrass
&& block != Blocks.deadbush
&& !block.isReplaceable(world, x, y, z)) {
if (side == 0) {
y--;
} else if (side == 1) {
y++;
} else if (side == 2) {
z--;
} else if (side == 3) {
z++;
} else if (side == 4) {
x--;
} else if (side == 5) {
x++;
}
}
return world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack);
}
if (world.getBlock(x, y, z) == block) {
block.onBlockPlacedBy(world, x, y, z, player, stack);
block.onPostBlockPlaced(world, x, y, z, metadata);
}
return true;
}
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ, int metadata) {
Block block = Botany.flower;
if (!world.setBlock(x, y, z, block, metadata, 3)) {
return false;
}
public abstract EnumFlowerStage getStage();
if (world.getBlock(x, y, z) == block) {
block.onBlockPlacedBy(world, x, y, z, player, stack);
block.onPostBlockPlaced(world, x, y, z, metadata);
}
return true;
}
public abstract String getTag();
public abstract EnumFlowerStage getStage();
public abstract String getTag();
}
@@ -3,17 +3,18 @@ package binnie.botany.flower;
import binnie.botany.api.EnumFlowerStage;
public class ItemFlower extends ItemBotany {
public ItemFlower() {
super("itemFlower");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.FLOWER;
}
public ItemFlower() {
super("itemFlower");
}
@Override
public String getTag() {
return "";
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.FLOWER;
}
@Override
public String getTag() {
return "";
}
}
@@ -1,10 +1,9 @@
package binnie.botany.flower;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,155 +12,150 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemInsulatedTube extends Item {
IIcon[] icons;
public ItemInsulatedTube() {
icons = new IIcon[3];
setUnlocalizedName("insulatedTube");
setCreativeTab(CreativeTabBotany.instance);
setHasSubtypes(true);
}
IIcon[] icons;
public static ItemStack getInsulateStack(ItemStack stack) {
return Insulate.get(stack.getItemDamage()).getStack();
}
public ItemInsulatedTube() {
icons = new IIcon[3];
setUnlocalizedName("insulatedTube");
setCreativeTab(CreativeTabBotany.instance);
setHasSubtypes(true);
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
}
}
}
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
for (int i = 0; i < 3; ++i) {
icons[i] = Botany.proxy.getIcon(register, "insulatedTube." + i);
}
}
public static ItemStack getInsulateStack(ItemStack stack) {
return Insulate.get(stack.getItemDamage()).getStack();
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) {
if (pass == 0) {
return 0xffffff;
}
return (pass == 1)
? Material.get(stack.getItemDamage()).getColor()
: Insulate.get(stack.getItemDamage()).getColor();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(Insulate.get(stack.getItemDamage()).getName());
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
for (int i = 0; i < 3; ++i) {
icons[i] = Botany.proxy.getIcon(register, "insulatedTube." + i);
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return Material.get(stack.getItemDamage()).getName() + " "
+ I18N.localise("botany.tube.name");
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) {
if (pass == 0) {
return 0xffffff;
}
return (pass == 1) ? Material.get(stack.getItemDamage()).getColor()
: Insulate.get(stack.getItemDamage()).getColor();
}
@Override
public int getRenderPasses(int metadata) {
return 3;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(Insulate.get(stack.getItemDamage()).getName());
}
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return icons[pass % 3];
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return Material.get(stack.getItemDamage()).getName() + " " + I18N.localise("botany.tube.name");
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
public int getRenderPasses(int metadata) {
return 3;
}
enum Material {
Copper(0xe3b78e, "cooper"),
Tin(0xe1eef4, "tin"),
Bronze(0xddc276, "bronze"),
Iron(0xd8d8d8, "iron");
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return icons[pass % 3];
}
protected int color;
protected String name;
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
Material(int color, String name) {
this.color = color;
this.name = name;
}
enum Material {
public static Material get(int i) {
return values()[i % values().length];
}
Copper(0xe3b78e, "copper"),
Tin(0xe1eef4, "tin"),
Bronze(0xddc276, "bronze"),
Iron(0xd8d8d8, "iron");
public int getColor() {
return color;
}
private final int color;
private final String name;
public String getName() {
return I18N.localise("botany.tube." + name);
}
}
Material(int color, String name) {
this.color = color;
this.name = name;
}
enum Insulate {
Clay(0xa1aacc, "clay"),
Cobble(0x7b7b7b, "cobblestone"),
Sand(0xefeab5, "sand"),
HardenedClay(0x935c43, "hardenedClay"),
Stone(0x6d6d6d, "smoothStone"),
Sandstone(0xc1b989, "sandstone");
public static Material get(int i) {
return values()[i % values().length];
}
protected int color;
protected String name;
public int getColor() {
return color;
}
Insulate(int color, String name) {
this.color = color;
this.name = name;
}
public String getName() {
return I18N.localise("botany.tube." + name);
}
}
public static Insulate get(int i) {
return values()[i / 128 % values().length];
}
enum Insulate {
public int getColor() {
return color;
}
Clay(0xa1aacc, "clay"),
Cobble(0x7b7b7b, "cobblestone"),
Sand(0xefeab5, "sand"),
HardenedClay(0x935c43, "hardenedClay"),
Stone(0x6d6d6d, "smoothStone"),
Sandstone(0xc1b989, "sandstone");
public String getName() {
return I18N.localise("botany.tube.insulate." + name);
}
private final int color;
private final String name;
public ItemStack getStack() {
switch (this) {
case Clay:
return new ItemStack(Blocks.clay);
Insulate(int color, String name) {
this.color = color;
this.name = name;
}
case Cobble:
return new ItemStack(Blocks.cobblestone);
public static Insulate get(int i) {
return values()[i / 128 % values().length];
}
case HardenedClay:
return new ItemStack(Blocks.hardened_clay);
public int getColor() {
return color;
}
case Sand:
return new ItemStack(Blocks.sand);
public String getName() {
return I18N.localise("botany.tube.insulate." + name);
}
case Sandstone:
return new ItemStack(Blocks.sandstone);
case Stone:
return new ItemStack(Blocks.stone);
}
return null;
}
}
public ItemStack getStack() {
return switch (this) {
case Clay -> new ItemStack(Blocks.clay);
case Cobble -> new ItemStack(Blocks.cobblestone);
case HardenedClay -> new ItemStack(Blocks.hardened_clay);
case Sand -> new ItemStack(Blocks.sand);
case Sandstone -> new ItemStack(Blocks.sandstone);
case Stone -> new ItemStack(Blocks.stone);
};
}
}
}
@@ -4,17 +4,18 @@ import binnie.botany.api.EnumFlowerStage;
import binnie.core.util.I18N;
public class ItemPollen extends ItemBotany {
public ItemPollen() {
super("pollen");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.POLLEN;
}
public ItemPollen() {
super("pollen");
}
@Override
public String getTag() {
return I18N.localise("botany.item.pollen.tag.name");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.POLLEN;
}
@Override
public String getTag() {
return I18N.localise("botany.item.pollen.tag.name");
}
}
@@ -4,17 +4,18 @@ import binnie.botany.api.EnumFlowerStage;
import binnie.core.util.I18N;
public class ItemSeed extends ItemBotany {
public ItemSeed() {
super("seed");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.SEED;
}
public ItemSeed() {
super("seed");
}
@Override
public String getTag() {
return I18N.localise("botany.item.germling.tag.name");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.SEED;
}
@Override
public String getTag() {
return I18N.localise("botany.item.germling.tag.name");
}
}
@@ -1,6 +1,5 @@
package binnie.botany.flower;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
@@ -8,53 +7,56 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RendererBotany implements ISimpleBlockRenderingHandler {
public static int renderID;
public static int pass;
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// ignored
}
public static int renderID;
public static int pass;
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
double d1 = x;
double d2 = y;
double d3 = z;
long i1 = x * 3129871 ^ z * 116129781L;
i1 = i1 * i1 * 42317861L + i1 * 11L;
d1 += ((i1 >> 16 & 0xFL) / 15.0f - 0.5) * 0.3;
d3 += ((i1 >> 24 & 0xFL) / 15.0f - 0.5) * 0.3;
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// ignored
}
for (int j = 0; j < 3; ++j) {
RendererBotany.pass = j;
int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
float f = (l >> 16 & 0xFF) / 255.0f;
float f2 = (l >> 8 & 0xFF) / 255.0f;
float f3 = (l & 0xFF) / 255.0f;
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
double d1 = x;
double d3 = z;
long i1 = x * 3129871L ^ z * 116129781L;
i1 = i1 * i1 * 42317861L + i1 * 11L;
d1 += ((i1 >> 16 & 0xFL) / 15.0f - 0.5) * 0.3;
d3 += ((i1 >> 24 & 0xFL) / 15.0f - 0.5) * 0.3;
if (EntityRenderer.anaglyphEnable) {
f = (f * 30.0f + f2 * 59.0f + f3 * 11.0f) / 100.0f;
f2 = (f * 30.0f + f2 * 70.0f) / 100.0f;
f3 = (f * 30.0f + f3 * 70.0f) / 100.0f;
}
tessellator.setColorOpaque_F(f, f2, f3);
IIcon iicon = block.getIcon(world, x, y, z, 0);
renderer.drawCrossedSquares(iicon, d1, d2, d3, 1.0f);
}
return false;
}
for (int j = 0; j < 3; ++j) {
RendererBotany.pass = j;
int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
float f = (l >> 16 & 0xFF) / 255.0f;
float f2 = (l >> 8 & 0xFF) / 255.0f;
float f3 = (l & 0xFF) / 255.0f;
@Override
public boolean shouldRender3DInInventory(int i) {
return false;
}
if (EntityRenderer.anaglyphEnable) {
f = (f * 30.0f + f2 * 59.0f + f3 * 11.0f) / 100.0f;
f2 = (f * 30.0f + f2 * 70.0f) / 100.0f;
f3 = (f * 30.0f + f3 * 70.0f) / 100.0f;
}
tessellator.setColorOpaque_F(f, f2, f3);
IIcon iicon = block.getIcon(world, x, y, z, 0);
renderer.drawCrossedSquares(iicon, d1, y, d3, 1.0f);
}
return false;
}
@Override
public int getRenderId() {
return RendererBotany.renderID;
}
@Override
public boolean shouldRender3DInInventory(int i) {
return false;
}
@Override
public int getRenderId() {
return RendererBotany.renderID;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,12 +1,9 @@
package binnie.botany.gardening;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -17,141 +14,145 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPlant extends BlockBush {
public BlockPlant() {
setBlockName("plant");
setCreativeTab(CreativeTabBotany.instance);
setTickRandomly(true);
setStepSound(Block.soundTypeGrass);
}
public static boolean isWeed(IBlockAccess world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof BlockPlant)) {
return false;
}
public BlockPlant() {
setBlockName("plant");
setCreativeTab(CreativeTabBotany.instance);
setTickRandomly(true);
setStepSound(Block.soundTypeGrass);
}
Type type = Type.get(world.getBlockMetadata(x, y, z));
return type == Type.Weeds
|| type == Type.WeedsLong
|| type == Type.WeedsVeryLong;
}
public static boolean isWeed(IBlockAccess world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof BlockPlant)) {
return false;
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<>();
}
Type type = Type.get(world.getBlockMetadata(x, y, z));
return type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (Type t : Type.values()) {
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
}
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<>();
}
@Override
protected boolean canPlaceBlockOn(Block block) {
return super.canPlaceBlockOn(block) || Gardening.isSoil(block);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (Type t : Type.values()) {
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return Type.values()[meta % Type.values().length].icon;
}
@Override
protected boolean canPlaceBlockOn(Block block) {
return super.canPlaceBlockOn(block) || Gardening.isSoil(block);
}
@Override
public int damageDropped(int damage) {
return damage;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return Type.values()[meta % Type.values().length].icon;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (Type type : Type.values()) {
list.add(type.get());
}
}
@Override
public int damageDropped(int damage) {
return damage;
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
Type type = Type.get(world.getBlockMetadata(x, y, z));
if (random.nextInt(4) == 0) {
if (type == Type.Weeds) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
} else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsVeryLong.ordinal(), 2);
} else if (type == Type.DeadFlower) {
world.setBlockMetadataWithNotify(x, y, z, Type.DecayingFlower.ordinal(), 2);
} else if (type == Type.DecayingFlower) {
world.setBlockToAir(x, y, z);
return;
}
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Type type : Type.values()) {
list.add(type.get());
}
}
if (random.nextInt(6) == 0) {
if (type == Type.Weeds) {
world.setBlockToAir(x, y, z);
} else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.Weeds.ordinal(), 2);
} else if (type == Type.WeedsVeryLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
Type type = Type.get(world.getBlockMetadata(x, y, z));
if (random.nextInt(4) == 0) {
if (type == Type.Weeds) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
} else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsVeryLong.ordinal(), 2);
} else if (type == Type.DeadFlower) {
world.setBlockMetadataWithNotify(x, y, z, Type.DecayingFlower.ordinal(), 2);
} else if (type == Type.DecayingFlower) {
world.setBlockToAir(x, y, z);
return;
}
}
Block below = world.getBlock(x, y - 1, z);
if (!Gardening.isSoil(below)) {
return;
}
if (random.nextInt(6) == 0) {
if (type == Type.Weeds) {
world.setBlockToAir(x, y, z);
} else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.Weeds.ordinal(), 2);
} else if (type == Type.WeedsVeryLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
}
}
IBlockSoil soil = (IBlockSoil) below;
if (random.nextInt(3) != 0) {
return;
}
Block below = world.getBlock(x, y - 1, z);
if (!Gardening.isSoil(below)) {
return;
}
if (type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong) {
if (!soil.degrade(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.degrade(world, x, y - 1, z, EnumSoilType.SOIL);
}
} else if (type == Type.DecayingFlower && !soil.fertilise(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.fertilise(world, x, y - 1, z, EnumSoilType.FLOWERBED);
}
}
IBlockSoil soil = (IBlockSoil) below;
if (random.nextInt(3) != 0) {
return;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
return true;
}
if (type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong) {
if (!soil.degrade(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.degrade(world, x, y - 1, z, EnumSoilType.SOIL);
}
} else if (type == Type.DecayingFlower && !soil.fertilise(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.fertilise(world, x, y - 1, z, EnumSoilType.FLOWERBED);
}
}
public enum Type {
Weeds("weeds"),
WeedsLong("longWeeds"),
WeedsVeryLong("veryLongWeeds"),
DeadFlower("deadFlower"),
DecayingFlower("decayingFlower");
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
return true;
}
public IIcon icon;
public enum Type {
protected String name;
Weeds("weeds"),
WeedsLong("longWeeds"),
WeedsVeryLong("veryLongWeeds"),
DeadFlower("deadFlower"),
DecayingFlower("decayingFlower");
Type(String name) {
this.name = name;
}
public IIcon icon;
public static Type get(int id) {
return values()[id % values().length];
}
private final String name;
public ItemStack get() {
return new ItemStack(Botany.plant, 1, ordinal());
}
Type(String name) {
this.name = name;
}
public String getName() {
return I18N.localise("botany.plant." + name);
}
}
public static Type get(int id) {
return values()[id % values().length];
}
public ItemStack get() {
return new ItemStack(Botany.plant, 1, ordinal());
}
public String getName() {
return I18N.localise("botany.plant." + name);
}
}
}
@@ -1,13 +1,8 @@
package binnie.botany.gardening;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -22,193 +17,201 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
import java.util.Random;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSoil extends Block implements IBlockSoil {
protected boolean weedKilled;
protected IIcon[] iconsTop;
protected IIcon[] iconsSide;
protected IIcon[] iconsNoWeed;
protected EnumSoilType type;
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
super(Material.ground);
this.type = type;
this.weedKilled = weedKilled;
iconsTop = new IIcon[9];
iconsSide = new IIcon[9];
iconsNoWeed = new IIcon[9];
setCreativeTab(CreativeTabBotany.instance);
setBlockName(blockName);
setTickRandomly(true);
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f);
setLightOpacity(255);
setHardness(0.5f);
setStepSound(Block.soundTypeGravel);
}
protected boolean weedKilled;
protected IIcon[] iconsTop;
protected IIcon[] iconsSide;
protected IIcon[] iconsNoWeed;
protected EnumSoilType type;
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
return acid.ordinal() * 3 + moisture.ordinal();
}
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
super(Material.ground);
this.type = type;
this.weedKilled = weedKilled;
iconsTop = new IIcon[9];
iconsSide = new IIcon[9];
iconsNoWeed = new IIcon[9];
setCreativeTab(CreativeTabBotany.instance);
setBlockName(blockName);
setTickRandomly(true);
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f);
setLightOpacity(255);
setHardness(0.5f);
setStepSound(Block.soundTypeGravel);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 9; ++i) {
list.add(new ItemStack(this, 1, i));
}
}
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
return acid.ordinal() * 3 + moisture.ordinal();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i < 9; ++i) {
list.add(new ItemStack(this, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
meta = ((meta >= 9) ? 8 : meta);
if (side == 1) {
return weedKilled ? iconsNoWeed[meta] : iconsTop[meta];
}
return (side == 0) ? Blocks.dirt.getIcon(side, 0) : iconsSide[meta];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumMoisture moisture : EnumMoisture.values()) {
for (EnumAcidity pH : EnumAcidity.values()) {
int index = moisture.ordinal() + pH.ordinal() * 3;
String id = "soil/" + getType().getID() + "." + pH.getID() + "." + moisture.getID();
iconsTop[index] = Botany.proxy.getIcon(register, id + ".0");
iconsSide[index] = Botany.proxy.getIcon(register, id + ".1");
iconsNoWeed[index] = Botany.proxy.getIcon(register, id + ".2");
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
meta = ((meta >= 9) ? 8 : meta);
if (side == 1) {
return weedKilled ? iconsNoWeed[meta] : iconsTop[meta];
}
return (side == 0) ? Blocks.dirt.getIcon(side, 0) : iconsSide[meta];
}
public EnumSoilType getType() {
return type;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumMoisture moisture : EnumMoisture.VALUES) {
for (EnumAcidity pH : EnumAcidity.VALUES) {
int index = moisture.ordinal() + pH.ordinal() * 3;
String id = "soil/" + getType().getID() + "." + pH.getID() + "." + moisture.getID();
iconsTop[index] = Botany.proxy.getIcon(register, id + ".0");
iconsSide[index] = Botany.proxy.getIcon(register, id + ".1");
iconsNoWeed[index] = Botany.proxy.getIcon(register, id + ".2");
}
}
}
@Override
public int damageDropped(int damage) {
return damage;
}
public EnumSoilType getType() {
return type;
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z);
if (desiredMoisture.ordinal() > moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
}
if (desiredMoisture.ordinal() < moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
}
@Override
public int damageDropped(int damage) {
return damage;
}
int meta2 = getMeta(acidity, moisture);
if (meta != meta2) {
world.setBlockMetadataWithNotify(x, y, z, meta2, 2);
}
if (!weedKilled && random.nextInt(5 - getType(world, x, y, z).ordinal()) == 0 && world.getBlock(x, y + 1, z) == Blocks.air) {
world.setBlock(x, y + 1, z, Botany.plant, BlockPlant.Type.Weeds.ordinal(), 2);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
EnumMoisture moisture = EnumMoisture.VALUES[meta % 3];
EnumAcidity acidity = EnumAcidity.VALUES[meta / 3];
EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z);
if (desiredMoisture.ordinal() > moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
}
if (desiredMoisture.ordinal() < moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
int meta2 = getMeta(acidity, moisture);
if (meta != meta2) {
world.setBlockMetadataWithNotify(x, y, z, meta2, 2);
}
if (!weedKilled && random.nextInt(5 - getType(world, x, y, z).ordinal()) == 0
&& world.getBlock(x, y + 1, z) == Blocks.air) {
world.setBlock(x, y + 1, z, Botany.plant, BlockPlant.Type.Weeds.ordinal(), 2);
}
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public EnumAcidity getPH(World world, int x, int y, int z) {
return EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3];
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public EnumMoisture getMoisture(World world, int x, int y, int z) {
return EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3];
}
@Override
public EnumAcidity getPH(World world, int x, int y, int z) {
return EnumAcidity.VALUES[world.getBlockMetadata(x, y, z) / 3];
}
@Override
public EnumSoilType getType(World world, int x, int y, int z) {
return type;
}
@Override
public EnumMoisture getMoisture(World world, int x, int y, int z) {
return EnumMoisture.VALUES[world.getBlockMetadata(x, y, z) % 3];
}
@Override
public boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel) {
EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() >= maxLevel.ordinal()) {
return false;
}
@Override
public EnumSoilType getType(World world, int x, int y, int z) {
return type;
}
int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(maxLevel, weedKilled), meta, 2);
}
@Override
public boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel) {
EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() >= maxLevel.ordinal()) {
return false;
}
@Override
public boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel) {
EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() <= minLevel.ordinal()) {
return false;
}
int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(maxLevel, weedKilled), meta, 2);
}
int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(minLevel, weedKilled), meta, 2);
}
@Override
public boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel) {
EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() <= minLevel.ordinal()) {
return false;
}
@Override
public boolean setPH(World world, int x, int y, int z, EnumAcidity pH) {
int meta = getMeta(pH, getMoisture(world, x, y, z));
return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(minLevel, weedKilled), meta, 2);
}
@Override
public boolean setMoisture(World world, int x, int y, int z, EnumMoisture moisture) {
int meta = getMeta(getPH(world, x, y, z), moisture);
return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
@Override
public boolean setPH(World world, int x, int y, int z, EnumAcidity pH) {
int meta = getMeta(pH, getMoisture(world, x, y, z));
return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, false)) {
world.setBlock(x, y, z, Blocks.dirt, 0, 2);
}
}
@Override
public boolean setMoisture(World world, int x, int y, int z, EnumMoisture moisture) {
int meta = getMeta(getPH(world, x, y, z), moisture);
return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
Block plant = plantable.getPlant(world, x, y + 1, z);
if (plant == Botany.flower) {
return true;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, false)) {
world.setBlock(x, y, z, Blocks.dirt, 0, 2);
}
}
if (plant == Botany.plant) {
return !weedKilled || !BlockPlant.isWeed(world, x, y, z);
}
return world instanceof World
&& Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable);
}
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction,
IPlantable plantable) {
Block plant = plantable.getPlant(world, x, y + 1, z);
if (plant == Botany.flower) {
return true;
}
@Override
public boolean resistsWeeds(World world, int x, int y, int z) {
return weedKilled;
}
if (plant == Botany.plant) {
return !weedKilled || !BlockPlant.isWeed(world, x, y, z);
}
return world instanceof World && Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable);
}
@Override
public boolean resistsWeeds(World world, int x, int y, int z) {
return weedKilled;
}
}
@@ -1,5 +1,20 @@
package binnie.botany.gardening;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import binnie.botany.Botany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
@@ -9,266 +24,259 @@ import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.items.BotanyItems;
import binnie.core.BinnieCore;
import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumTemperature;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
public class Gardening {
public static Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>();
public static boolean isSoil(Block block) {
return block instanceof IBlockSoil;
}
public static Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>();
public static boolean isSoil(Item item) {
return item instanceof ItemBlock
&& isSoil(((ItemBlock) item).field_150939_a);
}
public static boolean isSoil(Block block) {
return block instanceof IBlockSoil;
}
public static EnumMoisture getNaturalMoisture(World world, int x, int y, int z) {
float bias = getBiomeMoisture(world.getBiomeGenForCoords(x, z), y);
for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.sand) {
bias -= 1.5;
} else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) {
bias += 1.5;
}
}
}
}
public static boolean isSoil(Item item) {
return item instanceof ItemBlock && isSoil(((ItemBlock) item).field_150939_a);
}
if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) {
bias += 1.5;
}
public static EnumMoisture getNaturalMoisture(World world, int x, int y, int z) {
float bias = getBiomeMoisture(world.getBiomeGenForCoords(x, z), y);
for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.sand) {
bias -= 1.5f;
} else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) {
bias += 1.5f;
}
}
}
}
for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.gravel && bias > 0.0f) {
bias *= 0.4f;
}
}
}
}
if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) {
bias += 1.5f;
}
if (bias <= -1.0f) {
return EnumMoisture.DRY;
}
return (bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL;
}
for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.gravel && bias > 0.0f) {
bias *= 0.4f;
}
}
}
}
public static EnumAcidity getNaturalPH(World world, int x, int y, int z) {
float bias = getBiomePH(world.getBiomeGenForCoords(x, z), y);
if (bias <= -1.0f) {
return EnumAcidity.ACID;
}
return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL;
}
if (bias <= -1.0f) {
return EnumMoisture.DRY;
}
return (bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL;
}
public static float getBiomeMoisture(BiomeGenBase biome, int H) {
double R = biome.rainfall;
double T = biome.temperature;
double m = 3.2 * (R - 0.5) - 0.4 * (1.0 + T + 0.5 * T * T) + 1.1 - 1.6 * (T - 0.9) * (T - 0.9) - 0.002 * (H - 64);
if (m == 0.0) {
return (float) m;
}
if (m < 0.0){
return (float) -Math.sqrt(m * m);
}
return (float) Math.sqrt(m * m);
}
public static EnumAcidity getNaturalPH(World world, int x, int y, int z) {
float bias = getBiomePH(world.getBiomeGenForCoords(x, z), y);
if (bias <= -1.0f) {
return EnumAcidity.ACID;
}
return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL;
}
public static float getBiomePH(BiomeGenBase biome, int H) {
double R = biome.rainfall;
double T = biome.temperature;
return (float) (-3.0 * (R - 0.5) + 0.5 * (T - 0.699999988079071) * (T - 0.699999988079071) + 0.02f * (H - 64) - 0.15000000596046448);
}
public static float getBiomeMoisture(BiomeGenBase biome, int H) {
double R = biome.rainfall;
double T = biome.temperature;
double m = 3.2 * (R - 0.5) - 0.4 * (1.0 + T + 0.5 * T * T)
+ 1.1
- 1.6 * (T - 0.9) * (T - 0.9)
- 0.002 * (H - 64);
if (m == 0.0) {
return (float) m;
}
if (m < 0.0) {
return (float) -Math.sqrt(m * m);
}
return (float) Math.sqrt(m * m);
}
public static void createSoil(World world, int x, int y, int z, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
int meta = moisture.ordinal() + acidity.ordinal() * 3;
world.setBlock(x, y, z, getSoilBlock(soil), meta, 2);
}
public static float getBiomePH(BiomeGenBase biome, int H) {
double R = biome.rainfall;
double T = biome.temperature;
return (float) (-3.0 * (R - 0.5) + 0.5 * (T - 0.699999988079071) * (T - 0.699999988079071)
+ 0.02f * (H - 64)
- 0.15000000596046448);
}
public static boolean plant(World world, int x, int y, int z, IFlower flower, GameProfile owner) {
boolean set = world.setBlock(x, y, z, Botany.flower, 0, 2);
if (!set) {
return false;
}
public static void createSoil(World world, int x, int y, int z, EnumSoilType soil, EnumMoisture moisture,
EnumAcidity acidity) {
int meta = moisture.ordinal() + acidity.ordinal() * 3;
world.setBlock(x, y, z, getSoilBlock(soil), meta, 2);
}
TileEntity tileFlower = world.getTileEntity(x, y, z);
TileEntity below = world.getTileEntity(x, y - 1, z);
if (tileFlower != null && tileFlower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) {
((TileEntityFlower) tileFlower).setSection(((TileEntityFlower) below).getSection());
} else {
((TileEntityFlower) tileFlower).create(flower, owner);
}
}
public static boolean plant(World world, int x, int y, int z, IFlower flower, GameProfile owner) {
boolean set = world.setBlock(x, y, z, Botany.flower, 0, 2);
if (!set) {
return false;
}
tryGrowSection(world, x, y, z);
return true;
}
final TileEntity tile = world.getTileEntity(x, y, z);
final TileEntity below = world.getTileEntity(x, y - 1, z);
if (tile instanceof TileEntityFlower tileFlower) {
if (below instanceof TileEntityFlower lowerFlower) {
tileFlower.setSection(lowerFlower.getSection());
} else {
tileFlower.create(flower, owner);
}
}
public static void tryGrowSection(World world, int x, int y, int z) {
if (!BinnieCore.proxy.isSimulating(world)) {
return;
}
tryGrowSection(world, x, y, z);
return true;
}
TileEntity flower = world.getTileEntity(x, y, z);
if (flower == null || !(flower instanceof TileEntityFlower)) {
return;
}
public static void tryGrowSection(World world, int x, int y, int z) {
if (!BinnieCore.proxy.isSimulating(world)) {
return;
}
IFlower iflower = ((TileEntityFlower) flower).getFlower();
int section = ((TileEntityFlower) flower).getSection();
if (iflower == null || section >= iflower.getGenome().getPrimary().getType().getSections() - 1 || iflower.getAge() <= 0) {
return;
}
TileEntity flower = world.getTileEntity(x, y, z);
if (!(flower instanceof TileEntityFlower)) {
return;
}
world.setBlock(x, y + 1, z, Botany.flower, 0, 2);
TileEntity tileFlower = world.getTileEntity(x, y + 1, z);
if (tileFlower != null && tileFlower instanceof TileEntityFlower) {
((TileEntityFlower) tileFlower).setSection(section + 1);
}
}
IFlower iflower = ((TileEntityFlower) flower).getFlower();
int section = ((TileEntityFlower) flower).getSection();
if (iflower == null || section >= iflower.getGenome().getPrimary().getType().getSections() - 1
|| iflower.getAge() <= 0) {
return;
}
public static void onGrowFromSeed(World world, int x, int y, int z) {
tryGrowSection(world, x, y, z);
}
world.setBlock(x, y + 1, z, Botany.flower, 0, 2);
TileEntity tileFlower = world.getTileEntity(x, y + 1, z);
if (tileFlower instanceof TileEntityFlower) {
((TileEntityFlower) tileFlower).setSection(section + 1);
}
}
public static Collection<ItemStack> getAcidFertilisers() {
return Gardening.fertiliserAcid.keySet();
}
public static void onGrowFromSeed(World world, int x, int y, int z) {
tryGrowSection(world, x, y, z);
}
public static Collection<ItemStack> getAlkalineFertilisers() {
return Gardening.fertiliserAlkaline.keySet();
}
public static Collection<ItemStack> getAcidFertilisers() {
return Gardening.fertiliserAcid.keySet();
}
public static Collection<ItemStack> getNutrientFertilisers() {
return Gardening.fertiliserNutrient.keySet();
}
public static Collection<ItemStack> getAlkalineFertilisers() {
return Gardening.fertiliserAlkaline.keySet();
}
public static boolean isAcidFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAcidFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static Collection<ItemStack> getNutrientFertilisers() {
return Gardening.fertiliserNutrient.keySet();
}
public static boolean isAlkalineFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAlkalineFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static boolean isAcidFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAcidFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static boolean isNutrientFertiliser(ItemStack itemstack) {
for (ItemStack stack : getNutrientFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static boolean isAlkalineFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAlkalineFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static int getFertiliserStrength(ItemStack stack) {
if (stack == null) {
return 1;
}
public static boolean isNutrientFertiliser(ItemStack itemstack) {
for (ItemStack stack : getNutrientFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAcid.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
public static int getFertiliserStrength(ItemStack stack) {
if (stack == null) {
return 1;
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAlkaline.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAcid.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserNutrient.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
return 1;
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAlkaline.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
public static boolean canTolerate(IFlower flower, World world, int x, int y, int z) {
if (flower == null || flower.getGenome() == null) {
return false;
}
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserNutrient.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
return 1;
}
int soilMeta = world.getBlockMetadata(x, y - 1, z);
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.temperature));
}
public static boolean canTolerate(IFlower flower, World world, int x, int y, int z) {
if (flower == null || flower.getGenome() == null) {
return false;
}
public static EnumSoilType getSoilType(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) instanceof IBlockSoil) {
return ((IBlockSoil) world.getBlock(x, y, z)).getType(world, x, y, z);
}
return EnumSoilType.SOIL;
}
int soilMeta = world.getBlockMetadata(x, y - 1, z);
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
return canTolerate(
flower,
EnumAcidity.VALUES[soilMeta / 3 % 3],
EnumMoisture.VALUES[soilMeta % 3],
EnumTemperature.getFromValue(biome.temperature));
}
public static Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false);
}
public static EnumSoilType getSoilType(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) instanceof IBlockSoil) {
return ((IBlockSoil) world.getBlock(x, y, z)).getType(world, x, y, z);
}
return EnumSoilType.SOIL;
}
public static Block getSoilBlock(EnumSoilType type, boolean weedkill) {
switch (type) {
case FLOWERBED:
return weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed;
public static Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false);
}
case LOAM:
return weedkill ? Botany.loamNoWeed : Botany.loam;
}
return weedkill ? Botany.soilNoWeed : Botany.soil;
}
public static Block getSoilBlock(EnumSoilType type, boolean weedkill) {
return switch (type) {
case FLOWERBED -> weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed;
case LOAM -> weedkill ? Botany.loamNoWeed : Botany.loam;
default -> weedkill ? Botany.soilNoWeed : Botany.soil;
};
}
public static boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) {
return flower.getGenome().canTolerate(ePH)
&& flower.getGenome().canTolerate(eMoisture)
&& flower.getGenome().canTolerate(eTemp);
}
public static boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) {
return flower.getGenome().canTolerate(ePH) && flower.getGenome().canTolerate(eMoisture)
&& flower.getGenome().canTolerate(eTemp);
}
public static boolean isWeedkiller(ItemStack heldItem) {
return heldItem != null
&& heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
}
public static boolean isWeedkiller(ItemStack heldItem) {
return heldItem != null && heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
}
public static boolean addWeedKiller(World world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof IBlockSoil)) {
return false;
}
public static boolean addWeedKiller(World world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof IBlockSoil)) {
return false;
}
EnumSoilType type = getSoilType(world, x, y, z);
Block block = getSoilBlock(type, true);
boolean done = world.setBlock(x, y, z, block, world.getBlockMetadata(x, y, z), 2);
if (done && BlockPlant.isWeed(world, x, y + 1, z)) {
world.setBlockToAir(x, y + 1, z);
}
return done;
}
EnumSoilType type = getSoilType(world, x, y, z);
Block block = getSoilBlock(type, true);
boolean done = world.setBlock(x, y, z, block, world.getBlockMetadata(x, y, z), 2);
if (done && BlockPlant.isWeed(world, x, y + 1, z)) {
world.setBlockToAir(x, y + 1, z);
}
return done;
}
}
@@ -1,86 +1,80 @@
package binnie.botany.gardening;
import java.util.List;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import java.util.List;
import java.util.Locale;
public class ItemSoil extends ItemBlock {
protected EnumSoilType type;
private boolean noWeed;
protected EnumSoilType type;
public ItemSoil(Block block) {
super(block);
type = ((BlockSoil) field_150939_a).getType();
noWeed = ((BlockSoil) field_150939_a).weedKilled;
hasSubtypes = true;
}
private final boolean noWeed;
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
EnumMoisture moisture = EnumMoisture.values()[stack.getItemDamage() % 3];
EnumAcidity acidity = EnumAcidity.values()[stack.getItemDamage() / 3];
String info = "";
public ItemSoil(Block block) {
super(block);
type = ((BlockSoil) field_150939_a).getType();
noWeed = ((BlockSoil) field_150939_a).weedKilled;
hasSubtypes = true;
}
if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.moisture.dry")
+ EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DAMP) {
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.moisture.damp")
+ EnumChatFormatting.RESET;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
EnumMoisture moisture = EnumMoisture.VALUES[stack.getItemDamage() % 3];
EnumAcidity acidity = EnumAcidity.VALUES[stack.getItemDamage() / 3];
String info = "";
if (acidity == EnumAcidity.ACID) {
if (info.length() > 0) {
info += ", ";
}
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.ph.acid")
+ EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.dry") + EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DAMP) {
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.damp") + EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ALKALINE) {
if (info.length() > 0) {
info += ", ";
}
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.ph.alkaline")
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ACID) {
if (!info.isEmpty()) {
info += ", ";
}
info += EnumChatFormatting.YELLOW + I18N.localise("botany.ph.acid") + EnumChatFormatting.RESET;
}
if (info.length() > 0) {
tooltip.add(info);
}
if (acidity == EnumAcidity.ALKALINE) {
if (!info.isEmpty()) {
info += ", ";
}
info += EnumChatFormatting.YELLOW + I18N.localise("botany.ph.alkaline") + EnumChatFormatting.RESET;
}
if (noWeed) {
tooltip.add(I18N.localise("botany.soil.weedkiller"));
}
}
if (!info.isEmpty()) {
tooltip.add(info);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
String soilName = type.name().toLowerCase(Locale.ENGLISH);
return I18N.localise("botany.soil." + soilName);
}
if (noWeed) {
tooltip.add(I18N.localise("botany.soil.weedkiller"));
}
}
@Override
public int getMetadata(int meta) {
return meta;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
String soilName = type.name().toLowerCase(Locale.ENGLISH);
return I18N.localise("botany.soil." + soilName);
}
@Override
public int getMetadata(int meta) {
return meta;
}
}
@@ -1,5 +1,17 @@
package binnie.botany.gardening;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
@@ -11,74 +23,60 @@ import binnie.core.util.I18N;
import binnie.genetics.genetics.AlleleHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
public class ItemSoilMeter extends Item {
public ItemSoilMeter() {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("soilMeter");
setMaxStackSize(1);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float blockX, float blockY, float blockZ) {
Block block = world.getBlock(x, y, z);
if (!Gardening.isSoil(block)) {
y--;
block = world.getBlock(x, y, z);
}
public ItemSoilMeter() {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("soilMeter");
setMaxStackSize(1);
if (Gardening.isSoil(block) && !BinnieCore.proxy.isSimulating(world)) {
IBlockSoil soil = (IBlockSoil) block;
EnumSoilType type = soil.getType(world, x, y, z);
EnumMoisture moisture = soil.getMoisture(world, x, y, z);
EnumAcidity pH = soil.getPH(world, x, y, z);
registerItem(this, getUnlocalizedName().substring(5));
}
EnumChatFormatting[] colors = new EnumChatFormatting[]{
EnumChatFormatting.DARK_GRAY,
EnumChatFormatting.GOLD,
EnumChatFormatting.LIGHT_PURPLE,
};
String info = I18N.localise("botany.soil.tooltip.type") + " ";
info += colors[type.ordinal()] + AlleleHelper.toDisplay(type) + EnumChatFormatting.RESET;
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float blockX, float blockY, float blockZ) {
Block block = world.getBlock(x, y, z);
if (!Gardening.isSoil(block)) {
y--;
block = world.getBlock(x, y, z);
}
colors = new EnumChatFormatting[]{
EnumChatFormatting.YELLOW,
EnumChatFormatting.GRAY,
EnumChatFormatting.BLUE,
};
info += ", " + I18N.localise("botany.soil.tooltip.moisture") + " ";
info += colors[moisture.ordinal()] + AlleleHelper.toDisplay(moisture) + EnumChatFormatting.RESET;
if (Gardening.isSoil(block) && !BinnieCore.proxy.isSimulating(world)) {
IBlockSoil soil = (IBlockSoil) block;
EnumSoilType type = soil.getType(world, x, y, z);
EnumMoisture moisture = soil.getMoisture(world, x, y, z);
EnumAcidity pH = soil.getPH(world, x, y, z);
colors = new EnumChatFormatting[]{
EnumChatFormatting.RED,
EnumChatFormatting.GREEN,
EnumChatFormatting.AQUA,
};
info += ", " + I18N.localise("botany.soil.tooltip.pH") + " ";
info += colors[pH.ordinal()] + AlleleHelper.toDisplay(pH) + EnumChatFormatting.RESET;
IChatComponent chat = new ChatComponentText(info);
player.addChatMessage(chat);
}
return super.onItemUse(stack, player, world, x, y, z, side, blockX, blockY, blockZ);
}
EnumChatFormatting[] colors = new EnumChatFormatting[] { EnumChatFormatting.DARK_GRAY,
EnumChatFormatting.GOLD, EnumChatFormatting.LIGHT_PURPLE, };
String info = I18N.localise("botany.soil.tooltip.type") + " ";
info += colors[type.ordinal()] + AlleleHelper.toDisplay(type) + EnumChatFormatting.RESET;
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "soilMeter");
}
colors = new EnumChatFormatting[] { EnumChatFormatting.YELLOW, EnumChatFormatting.GRAY,
EnumChatFormatting.BLUE, };
info += ", " + I18N.localise("botany.soil.tooltip.moisture") + " ";
info += colors[moisture.ordinal()] + AlleleHelper.toDisplay(moisture) + EnumChatFormatting.RESET;
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.soilMeter.name");
}
colors = new EnumChatFormatting[] { EnumChatFormatting.RED, EnumChatFormatting.GREEN,
EnumChatFormatting.AQUA, };
info += ", " + I18N.localise("botany.soil.tooltip.pH") + " ";
info += colors[pH.ordinal()] + AlleleHelper.toDisplay(pH) + EnumChatFormatting.RESET;
IChatComponent chat = new ChatComponentText(info);
player.addChatMessage(chat);
}
return super.onItemUse(stack, player, world, x, y, z, side, blockX, blockY, blockZ);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "soilMeter");
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.soilMeter.name");
}
}
@@ -1,12 +1,7 @@
package binnie.botany.gardening;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -15,53 +10,72 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemTrowel extends Item {
protected Item.ToolMaterial theToolMaterial;
String locName;
public ItemTrowel(Item.ToolMaterial toolMaterial, String material) {
theToolMaterial = toolMaterial;
maxStackSize = 1;
setMaxDamage(toolMaterial.getMaxUses());
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("trowel" + material);
locName = "trowel" + material;
}
protected Item.ToolMaterial theToolMaterial;
String locName;
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "tools/" + locName);
}
public ItemTrowel(Item.ToolMaterial toolMaterial, String material) {
theToolMaterial = toolMaterial;
maxStackSize = 1;
setMaxDamage(toolMaterial.getMaxUses());
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("trowel" + material);
locName = "trowel" + material;
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float blockX, float blockY, float blockZ) {
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}
Block block = world.getBlock(x, y, z);
if (side == 0 ||
(!world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && world.getBlock(x, y + 1, z) != Botany.flower) ||
(block != Blocks.grass && block != Blocks.dirt)) {
return false;
}
registerItem(this, getUnlocalizedName().substring(5));
}
Block block2 = Botany.soil;
world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, block2.stepSound.getStepResourcePath(), (block2.stepSound.getVolume() + 1.0f) / 2.0f, block2.stepSound.getPitch() * 0.8f);
if (world.isRemote) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "tools/" + locName);
}
EnumMoisture moisture = Gardening.getNaturalMoisture(world, x, y, z);
EnumAcidity acidity = Gardening.getNaturalPH(world, x, y, z);
Gardening.createSoil(world, x, y, z, EnumSoilType.SOIL, moisture, acidity);
stack.damageItem(1, player);
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float blockX, float blockY, float blockZ) {
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}
Block block = world.getBlock(x, y, z);
if (side == 0
|| (!world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
&& world.getBlock(x, y + 1, z) != Botany.flower)
|| (block != Blocks.grass && block != Blocks.dirt)) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
Block block2 = Botany.soil;
world.playSoundEffect(
x + 0.5f,
y + 0.5f,
z + 0.5f,
block2.stepSound.getStepResourcePath(),
(block2.stepSound.getVolume() + 1.0f) / 2.0f,
block2.stepSound.getPitch() * 0.8f);
if (world.isRemote) {
return true;
}
EnumMoisture moisture = Gardening.getNaturalMoisture(world, x, y, z);
EnumAcidity acidity = Gardening.getNaturalPH(world, x, y, z);
Gardening.createSoil(world, x, y, z, EnumSoilType.SOIL, moisture, acidity);
stack.damageItem(1, player);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
}
@@ -1,32 +1,34 @@
package binnie.botany.gardening;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemWeed extends ItemBlock {
public ItemWeed(Block block) {
super(block);
setHasSubtypes(true);
hasSubtypes = true;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
}
public ItemWeed(Block block) {
super(block);
setHasSubtypes(true);
hasSubtypes = true;
}
@Override
public int getMetadata(int meta) {
return meta;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return field_150939_a.getIcon(2, damage);
}
@Override
public int getMetadata(int meta) {
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return field_150939_a.getIcon(2, damage);
}
}
@@ -1,6 +1,17 @@
package binnie.botany.gardening;
import binnie.Binnie;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
@@ -25,346 +36,335 @@ import binnie.core.block.ItemMetadata;
import binnie.core.block.ItemMetadataRenderer;
import binnie.core.block.MultipassItemRenderer;
import binnie.core.block.TileEntityMetadata;
import binnie.core.item.ItemMisc;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.HashMap;
import java.util.Map;
public class ModuleGardening implements IInitializable {
public static HashMap<ItemStack, Integer> queuedAcidFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>();
@Override
public void preInit() {
Botany.plant = new BlockPlant();
GameRegistry.registerBlock(Botany.plant, ItemWeed.class, "plant");
public static HashMap<ItemStack, Integer> queuedAcidFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>();
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
GameRegistry.registerBlock(Botany.soil, ItemSoil.class, "soil");
@Override
public void preInit() {
Botany.plant = new BlockPlant();
GameRegistry.registerBlock(Botany.plant, ItemWeed.class, "plant");
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
GameRegistry.registerBlock(Botany.loam, ItemSoil.class, "loam");
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
GameRegistry.registerBlock(Botany.soil, ItemSoil.class, "soil");
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
GameRegistry.registerBlock(Botany.flowerbed, ItemSoil.class, "flowerbed");
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
GameRegistry.registerBlock(Botany.loam, ItemSoil.class, "loam");
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soilNoWeed", true);
GameRegistry.registerBlock(Botany.soilNoWeed, ItemSoil.class, "soilNoWeed");
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
GameRegistry.registerBlock(Botany.flowerbed, ItemSoil.class, "flowerbed");
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loamNoWeed", true);
GameRegistry.registerBlock(Botany.loamNoWeed, ItemSoil.class, "loamNoWeed");
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soilNoWeed", true);
GameRegistry.registerBlock(Botany.soilNoWeed, ItemSoil.class, "soilNoWeed");
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbedNoWeed", true);
GameRegistry.registerBlock(Botany.flowerbedNoWeed, ItemSoil.class, "flowerbedNoWeed");
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loamNoWeed", true);
GameRegistry.registerBlock(Botany.loamNoWeed, ItemSoil.class, "loamNoWeed");
Botany.soilMeter = new ItemSoilMeter();
Botany.insulatedTube = new ItemInsulatedTube();
Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "Wood");
Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "Stone");
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "Iron");
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.EMERALD, "Diamond");
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "Gold");
Botany.misc = Binnie.Item.registerMiscItems(BotanyItems.values(), CreativeTabBotany.instance);
Botany.pigment = new ItemPigment();
Botany.clay = new ItemClay();
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbedNoWeed", true);
GameRegistry.registerBlock(Botany.flowerbedNoWeed, ItemSoil.class, "flowerbedNoWeed");
Botany.ceramic = new BlockCeramic();
GameRegistry.registerBlock(Botany.ceramic, ItemMetadata.class, "ceramic");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
Botany.soilMeter = new ItemSoilMeter();
Botany.insulatedTube = new ItemInsulatedTube();
Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "Wood");
Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "Stone");
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "Iron");
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.EMERALD, "Diamond");
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "Gold");
Botany.misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
Botany.pigment = new ItemPigment();
Botany.clay = new ItemClay();
Botany.stained = new BlockStained();
GameRegistry.registerBlock(Botany.stained, ItemMetadata.class, "stained");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
Botany.ceramic = new BlockCeramic();
GameRegistry.registerBlock(Botany.ceramic, ItemMetadata.class, "ceramic");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
Botany.ceramicTile = new BlockCeramicPatterned();
GameRegistry.registerBlock(Botany.ceramicTile, ItemMetadata.class, "ceramicPattern");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
Botany.stained = new BlockStained();
GameRegistry.registerBlock(Botany.stained, ItemMetadata.class, "stained");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
Botany.ceramicBrick = new BlockCeramicBrick();
GameRegistry.registerBlock(Botany.ceramicBrick, ItemMetadata.class, "ceramicBrick");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
}
Botany.ceramicTile = new BlockCeramicPatterned();
GameRegistry.registerBlock(Botany.ceramicTile, ItemMetadata.class, "ceramicPattern");
BinnieCore.proxy
.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
@Override
public void init() {
OreDictionary.registerOre("pigment", Botany.pigment);
RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, "");
RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, "");
ItemStack yellow = new ItemStack(Blocks.yellow_flower, 1);
ItemStack red = new ItemStack(Blocks.red_flower, 1);
ItemStack blue = new ItemStack(Blocks.red_flower, 1, 7);
Botany.ceramicBrick = new BlockCeramicBrick();
GameRegistry.registerBlock(Botany.ceramicBrick, ItemMetadata.class, "ceramicBrick");
BinnieCore.proxy
.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
}
for (boolean manual : new boolean[]{true, false}) {
for (boolean fertilised : new boolean[]{true, false}) {
for (EnumMoisture moist : EnumMoisture.values()) {
ItemStack icon = (moist == EnumMoisture.DRY) ? yellow : ((moist == EnumMoisture.NORMAL) ? red : blue);
int insulate = 2 - moist.ordinal();
if (fertilised) {
insulate += 3;
}
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate), icon);
}
}
}
}
@Override
public void init() {
OreDictionary.registerOre("pigment", Botany.pigment);
RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, "");
RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, "");
ItemStack yellow = new ItemStack(Blocks.yellow_flower, 1);
ItemStack red = new ItemStack(Blocks.red_flower, 1);
ItemStack blue = new ItemStack(Blocks.red_flower, 1, 7);
@Override
public void postInit() {
GameRegistry.addRecipe(new CeramicTileRecipe());
for (int mat = 0; mat < 4; ++mat) {
for (int insulate = 0; insulate < 6; ++insulate) {
ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
ItemStack forestryTube = new ItemStack(Mods.forestry.item("thermionicTubes"), 1, mat);
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
}
}
for (boolean manual : new boolean[] { true, false }) {
for (boolean fertilised : new boolean[] { true, false }) {
for (EnumMoisture moist : EnumMoisture.VALUES) {
ItemStack icon = (moist == EnumMoisture.DRY) ? yellow
: ((moist == EnumMoisture.NORMAL) ? red : blue);
int insulate = 2 - moist.ordinal();
if (fertilised) {
insulate += 3;
}
new CircuitGarden(
moist,
null,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 128 * insulate),
icon);
new CircuitGarden(
moist,
EnumAcidity.ACID,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate),
icon);
new CircuitGarden(
moist,
EnumAcidity.NEUTRAL,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate),
icon);
new CircuitGarden(
moist,
EnumAcidity.ALKALINE,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate),
icon);
}
}
}
}
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.soil, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.loam, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.soilNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.loamNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbedNoWeed, 1, OreDictionary.WILDCARD_VALUE));
@Override
public void postInit() {
GameRegistry.addRecipe(new CeramicTileRecipe());
for (int mat = 0; mat < 4; ++mat) {
for (int insulate = 0; insulate < 6; ++insulate) {
ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
ItemStack forestryTube = new ItemStack(Mods.forestry.item("thermionicTubes"), 1, mat);
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
}
}
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelWood,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "plankWood"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelStone,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "cobblestone"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelIron,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "ingotIron"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelGold,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "ingotGold"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelDiamond,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "gemDiamond"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.soilMeter,
new Object[]{
" gg", " rg", "i ",
'g', "ingotGold",
'r', "dustRedstone",
'i', "ingotIron"
}
));
GameRegistry.addShapelessRecipe(
BotanyItems.Weedkiller.get(4),
new ItemStack(Items.spider_eye),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds)
);
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.soil, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.loam, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.flowerbed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.soilNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.loamNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt),
new ItemStack(Botany.flowerbedNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.forestry.stack("ash"));
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.forestry.stack("mulch"));
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.forestry.stack("fertilizerBio"));
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.forestry.stack("fertilizerCompound"));
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.forestry.stack("woodPulp"));
GameRegistry.addRecipe(new ShapelessOreRecipe(
BotanyItems.SulphurPowder.get(4),
new Object[]{"dustSulphur"}
));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.trowelWood,
new Object[] { "d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "plankWood" }));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.trowelStone,
new Object[] { "d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "cobblestone" }));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.trowelIron,
new Object[] { "d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "ingotIron" }));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.trowelGold,
new Object[] { "d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "ingotGold" }));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.trowelDiamond,
new Object[] { "d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "gemDiamond" }));
GameRegistry.addRecipe(
new ShapedOreRecipe(
Botany.soilMeter,
new Object[] { " gg", " rg", "i ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron" }));
GameRegistry.addShapelessRecipe(
BotanyItems.Weedkiller.get(4),
new ItemStack(Items.spider_eye),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds));
GameRegistry.addRecipe(new ShapelessOreRecipe(
new ItemStack(Botany.pigment, 2, EnumFlowerColor.BLACK.ordinal()),
new Object[]{
"pigment",
"pigment",
"dyeBlack"
}
));
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.forestry.stack("ash"));
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.forestry.stack("mulch"));
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.forestry.stack("fertilizerBio"));
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.forestry.stack("fertilizerCompound"));
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.forestry.stack("woodPulp"));
GameRegistry
.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), new Object[] { "dustSulphur" }));
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "mulch")), 2);
GameRegistry.addRecipe(
new ShapelessOreRecipe(
new ItemStack(Botany.pigment, 2, EnumFlowerColor.BLACK.ordinal()),
new Object[] { "pigment", "pigment", "dyeBlack" }));
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
ModuleGardening.queuedAcidFertilisers.put(stack, 2);
}
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "mulch")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "ash")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "woodPulp")), 2);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerBio")), 2);
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerCompound")), 2);
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
ModuleGardening.queuedAcidFertilisers.put(stack, 2);
}
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
addAcidFertiliser(entry.getKey(), entry.getValue());
}
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "ash")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "woodPulp")), 2);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers
.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerBio")), 2);
ModuleGardening.queuedNutrientFertilisers
.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerCompound")), 2);
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
addAlkalineFertiliser(entry.getKey(), entry.getValue());
}
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
addAcidFertiliser(entry.getKey(), entry.getValue());
}
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
addNutrientFertiliser(entry.getKey(), entry.getValue());
}
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
addAlkalineFertiliser(entry.getKey(), entry.getValue());
}
GameRegistry.addRecipe(
BotanyItems.Mortar.get(6),
" c ", "cgc", " c ",
'c', Items.clay_ball,
'g', Blocks.gravel
);
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
addNutrientFertiliser(entry.getKey(), entry.getValue());
}
for (EnumFlowerColor c : EnumFlowerColor.values()) {
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment);
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f);
ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
glass.stackSize = 4;
GameRegistry.addShapedRecipe(
glass,
" g ", "gpg", " g ",
'g', Blocks.glass,
'p', pigment
);
}
GameRegistry
.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.clay_ball, 'g', Blocks.gravel);
GameRegistry.addRecipe(new PigmentRecipe());
}
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment);
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f);
ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
glass.stackSize = 4;
GameRegistry.addShapedRecipe(glass, " g ", "gpg", " g ", 'g', Blocks.glass, 'p', pigment);
}
private ItemStack getStack(int type, int pH, int moisture) {
if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) {
return null;
}
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
}
GameRegistry.addRecipe(new PigmentRecipe());
}
private void addAcidFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
private ItemStack getStack(int type, int pH, int moisture) {
if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) {
return null;
}
return new ItemStack(
Gardening.getSoilBlock(EnumSoilType.VALUES[type]),
1,
BlockSoil.getMeta(EnumAcidity.VALUES[pH], EnumMoisture.VALUES[moisture]));
}
Gardening.fertiliserAcid.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH - strength, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
private void addAcidFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
private void addAlkalineFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserAcid.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH - strength, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
Gardening.fertiliserAlkaline.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH + strength, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
private void addAlkalineFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
private void addNutrientFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserAlkaline.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH + strength, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
Gardening.fertiliserNutrient.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type + strength, pH, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
private void addNutrientFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserNutrient.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type + strength, pH, moisture);
if (end != null) {
end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
}
}
@@ -3,43 +3,43 @@ package binnie.botany.genetics;
import forestry.api.genetics.IAlleleInteger;
public class AlleleColor implements IAlleleInteger {
private String uid;
private int value;
private EnumFlowerColor color;
private boolean dominant = true;
public AlleleColor(EnumFlowerColor color, String uid, int value) {
this.color = color;
this.uid = uid;
this.value = value;
}
private final String uid;
private final int value;
private final EnumFlowerColor color;
@Override
public String getUID() {
return uid;
}
public AlleleColor(EnumFlowerColor color, String uid, int value) {
this.color = color;
this.uid = uid;
this.value = value;
}
@Override
public boolean isDominant() {
return dominant;
}
@Override
public String getUID() {
return uid;
}
@Override
public String getName() {
return color.getName();
}
@Override
public boolean isDominant() {
return true;
}
@Override
public int getValue() {
return value;
}
@Override
public String getName() {
return color.getName();
}
public EnumFlowerColor getColor() {
return color;
}
@Override
public int getValue() {
return value;
}
@Override
public String getUnlocalizedName() {
return getUID();
}
public EnumFlowerColor getColor() {
return color;
}
@Override
public String getUnlocalizedName() {
return getUID();
}
}
@@ -1,44 +1,46 @@
package binnie.botany.genetics;
import net.minecraft.world.World;
import binnie.botany.api.IAlleleFlowerEffect;
import binnie.botany.api.IFlowerGenome;
import binnie.core.util.I18N;
import forestry.api.genetics.IEffectData;
import net.minecraft.world.World;
public class AlleleEffectNone implements IAlleleFlowerEffect {
@Override
public boolean isCombinable() {
return true;
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
return storedData;
}
@Override
public boolean isCombinable() {
return true;
}
@Override
public String getUID() {
return "binnie.flowerEffectNone";
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
return storedData;
}
@Override
public boolean isDominant() {
return false;
}
@Override
public String getUID() {
return "binnie.flowerEffectNone";
}
@Override
public String getName() {
return I18N.localise("forestry.allele.effect.none");
}
@Override
public boolean isDominant() {
return false;
}
@Override
public IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z) {
return storedData;
}
@Override
public String getName() {
return I18N.localise("forestry.allele.effect.none");
}
@Override
public String getUnlocalizedName() {
return getUID();
}
@Override
public IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z) {
return storedData;
}
@Override
public String getUnlocalizedName() {
return getUID();
}
}
@@ -1,30 +1,31 @@
package binnie.botany.genetics;
import net.minecraft.entity.player.EntityPlayer;
import binnie.Binnie;
import binnie.botany.api.IBotanistTracker;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.core.genetics.BreedingTracker;
import net.minecraft.entity.player.EntityPlayer;
public class BotanistTracker extends BreedingTracker implements IBotanistTracker {
public BotanistTracker(String s) {
super(s);
}
@Override
public void registerPickup(IIndividual individual) {
// ignored
}
public BotanistTracker(String s) {
super(s);
}
@Override
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return Binnie.Genetics.getFlowerRoot()
.getBreedingTracker(player.worldObj, player.getGameProfile());
}
@Override
public void registerPickup(IIndividual individual) {
// ignored
}
@Override
protected String speciesRootUID() {
return "rootFlowers";
}
@Override
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return Binnie.Genetics.getFlowerRoot().getBreedingTracker(player.worldObj, player.getGameProfile());
}
@Override
protected String speciesRootUID() {
return "rootFlowers";
}
}
@@ -4,41 +4,41 @@ import binnie.botany.api.IColourMix;
import binnie.botany.api.IFlowerColor;
public class ColorMix implements IColourMix {
protected IFlowerColor color1;
protected IFlowerColor color2;
protected IFlowerColor result;
protected int chance;
public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) {
this.color1 = color1;
this.color2 = color2;
this.result = result;
this.chance = chance;
}
protected IFlowerColor color1;
protected IFlowerColor color2;
protected IFlowerColor result;
protected int chance;
@Override
public IFlowerColor getColor1() {
return color1;
}
public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) {
this.color1 = color1;
this.color2 = color2;
this.result = result;
this.chance = chance;
}
@Override
public IFlowerColor getColor2() {
return color2;
}
@Override
public IFlowerColor getColor1() {
return color1;
}
@Override
public boolean isMutation(IFlowerColor color1, IFlowerColor color2) {
return (color1 == this.color1 && color2 == this.color2)
|| (color1 == this.color2 && color2 == this.color1);
}
@Override
public IFlowerColor getColor2() {
return color2;
}
@Override
public int getChance() {
return chance;
}
@Override
public boolean isMutation(IFlowerColor color1, IFlowerColor color2) {
return (color1 == this.color1 && color2 == this.color2) || (color1 == this.color2 && color2 == this.color1);
}
@Override
public IFlowerColor getResult() {
return result;
}
@Override
public int getChance() {
return chance;
}
@Override
public IFlowerColor getResult() {
return result;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,152 +1,158 @@
package binnie.botany.genetics;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlowerType;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public enum EnumFlowerType implements IFlowerType {
DANDELION,
POPPY,
ORCHID,
ALLIUM,
BLUET,
TULIP,
DAISY,
CORNFLOWER,
PANSY,
IRIS,
LAVENDER(2),
VIOLA,
DAFFODIL,
DAHLIA,
PEONY(2),
ROSE(2),
LILAC(2),
HYDRANGEA(2),
FOXGLOVE(2),
ZINNIA,
MUMS,
MARIGOLD,
GERANIUM,
AZALEA,
PRIMROSE,
ASTER,
CARNATION,
LILY,
YARROW,
PETUNIA,
AGAPANTHUS,
FUCHSIA,
DIANTHUS,
FORGET,
ANEMONE,
AQUILEGIA,
EDELWEISS,
SCABIOUS,
CONEFLOWER,
GAILLARDIA,
AURICULA,
CAMELLIA(2),
GOLDENROD(2),
ALTHEA(2),
PENSTEMON(2),
DELPHINIUM(2),
HOLLYHOCK(2);
protected int sections;
protected IIcon[] stem;
protected IIcon[] petal;
protected IIcon[] variant;
protected IIcon[] unflowered;
protected IIcon seedStem;
protected IIcon seedPetal;
protected IIcon seedVariant;
protected IIcon pollenStem;
protected IIcon pollenPetal;
protected IIcon pollenVariant;
protected IIcon blank;
DANDELION,
POPPY,
ORCHID,
ALLIUM,
BLUET,
TULIP,
DAISY,
CORNFLOWER,
PANSY,
IRIS,
LAVENDER(2),
VIOLA,
DAFFODIL,
DAHLIA,
PEONY(2),
ROSE(2),
LILAC(2),
HYDRANGEA(2),
FOXGLOVE(2),
ZINNIA,
MUMS,
MARIGOLD,
GERANIUM,
AZALEA,
PRIMROSE,
ASTER,
CARNATION,
LILY,
YARROW,
PETUNIA,
AGAPANTHUS,
FUCHSIA,
DIANTHUS,
FORGET,
ANEMONE,
AQUILEGIA,
EDELWEISS,
SCABIOUS,
CONEFLOWER,
GAILLARDIA,
AURICULA,
CAMELLIA(2),
GOLDENROD(2),
ALTHEA(2),
PENSTEMON(2),
DELPHINIUM(2),
HOLLYHOCK(2);
EnumFlowerType() {
this(1);
}
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumFlowerType[] VALUES = values();
private final int sections;
private final IIcon[] stem;
private final IIcon[] petal;
private final IIcon[] variant;
private final IIcon[] unflowered;
private IIcon seedStem;
private IIcon seedPetal;
private IIcon seedVariant;
private IIcon pollenStem;
private IIcon pollenPetal;
private IIcon pollenVariant;
private IIcon blank;
EnumFlowerType(int sections) {
this.sections = sections;
stem = new IIcon[sections];
petal = new IIcon[sections];
variant = new IIcon[sections];
unflowered = new IIcon[sections];
}
EnumFlowerType() {
this(1);
}
@Override
public IIcon getStem(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedStem;
}
if (stage == EnumFlowerStage.POLLEN) {
return pollenStem;
}
return stem[section % sections];
}
EnumFlowerType(int sections) {
this.sections = sections;
stem = new IIcon[sections];
petal = new IIcon[sections];
variant = new IIcon[sections];
unflowered = new IIcon[sections];
}
@Override
public IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedPetal;
}
if (stage == EnumFlowerStage.POLLEN){
return pollenPetal;
}
if (flowered) {
return petal[section % sections];
}
return unflowered[section % sections];
}
@Override
public IIcon getStem(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedStem;
}
if (stage == EnumFlowerStage.POLLEN) {
return pollenStem;
}
return stem[section % sections];
}
@Override
public IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedVariant;
}
if (stage == EnumFlowerStage.POLLEN) {
return pollenVariant;
}
return flowered ? variant[section % sections] : blank;
}
@Override
public IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedPetal;
}
if (stage == EnumFlowerStage.POLLEN) {
return pollenPetal;
}
if (flowered) {
return petal[section % sections];
}
return unflowered[section % sections];
}
public void registerIcons(IIconRegister register) {
for (int i = 0; i < sections; ++i) {
String suf = (i == 0) ? "" : ("" + (i + 1));
String pre = (sections == 1) ? "" : "double/";
String id = pre + toString().toLowerCase() + suf;
stem[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".0");
petal[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".1");
variant[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".2");
unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".3");
}
@Override
public IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) {
return seedVariant;
}
if (stage == EnumFlowerStage.POLLEN) {
return pollenVariant;
}
return flowered ? variant[section % sections] : blank;
}
blank = Botany.proxy.getIcon(register, "flowers/blank");
seedStem = Botany.proxy.getIcon(register, "flowers/seed.0");
seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1");
seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2");
pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0");
pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1");
pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2");
}
public void registerIcons(IIconRegister register) {
for (int i = 0; i < sections; ++i) {
String suf = (i == 0) ? "" : ("" + (i + 1));
String pre = (sections == 1) ? "" : "double/";
String id = pre + toString().toLowerCase() + suf;
stem[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".0");
petal[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".1");
variant[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".2");
unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".3");
}
@Override
public int getID() {
return ordinal();
}
blank = Botany.proxy.getIcon(register, "flowers/blank");
seedStem = Botany.proxy.getIcon(register, "flowers/seed.0");
seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1");
seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2");
pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0");
pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1");
pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2");
}
@Override
public int getSections() {
return sections;
}
@Override
public int getID() {
return ordinal();
}
public IIcon getBlank() {
return blank;
}
@Override
public int getSections() {
return sections;
}
public IIcon getBlank() {
return blank;
}
}
+226 -209
View File
@@ -1,5 +1,11 @@
package binnie.botany.genetics;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IColourMix;
@@ -15,249 +21,260 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Individual;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import java.util.List;
public class Flower extends Individual implements IFlower {
public IFlowerGenome genome;
public IFlowerGenome mate;
protected int age;
protected boolean wilting;
protected boolean flowered;
public IFlowerGenome genome;
public IFlowerGenome mate;
public Flower(NBTTagCompound nbttagcompound) {
age = 0;
wilting = false;
readFromNBT(nbttagcompound);
}
protected int age;
protected boolean wilting;
protected boolean flowered;
public Flower(IFlowerGenome genome, int age) {
this.genome = genome;
this.age = age;
wilting = false;
flowered = age > 0;
}
public Flower(NBTTagCompound nbttagcompound) {
age = 0;
wilting = false;
readFromNBT(nbttagcompound);
}
@Override
public String getDisplayName() {
IAlleleFlowerSpecies species = getGenome().getPrimary();
String name = "";
if (species != null) {
name += species.getName();
}
return name;
}
public Flower(IFlowerGenome genome, int age) {
this.genome = genome;
this.age = age;
wilting = false;
flowered = age > 0;
}
@Override
public void addTooltip(List<String> list) {
IAlleleFlowerSpecies primary = genome.getPrimary();
IAlleleFlowerSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumFlowerChromosome.SPECIES)) {
list.add(EnumChatFormatting.BLUE + I18N.localise("botany.item.tooltip.hybrid", primary.getName(), secondary.getName()));
}
@Override
public String getDisplayName() {
IAlleleFlowerSpecies species = getGenome().getPrimary();
String name = "";
if (species != null) {
name += species.getName();
}
return name;
}
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.age", getAge()));
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.temperature", AlleleHelper.toDisplay(primary.getTemperature()), AlleleHelper.toDisplay(genome.getToleranceTemperature())));
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.moisture", AlleleHelper.toDisplay(primary.getMoisture()), AlleleHelper.toDisplay(genome.getToleranceMoisture())));
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.pH", AlleleHelper.toDisplay(primary.getHumidity()), AlleleHelper.toDisplay(genome.getTolerancePH())));
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.fertility", genome.getFertility()));
}
@Override
public void addTooltip(List<String> list) {
IAlleleFlowerSpecies primary = genome.getPrimary();
IAlleleFlowerSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumFlowerChromosome.SPECIES)) {
list.add(
EnumChatFormatting.BLUE
+ I18N.localise("botany.item.tooltip.hybrid", primary.getName(), secondary.getName()));
}
@Override
public String getIdent() {
return getGenome().getPrimary().getUID();
}
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.age", getAge()));
list.add(
EnumChatFormatting.GREEN + I18N.localise(
"botany.item.tooltip.temperature",
AlleleHelper.toDisplay(primary.getTemperature()),
AlleleHelper.toDisplay(genome.getToleranceTemperature())));
list.add(
EnumChatFormatting.GREEN + I18N.localise(
"botany.item.tooltip.moisture",
AlleleHelper.toDisplay(primary.getMoisture()),
AlleleHelper.toDisplay(genome.getToleranceMoisture())));
list.add(
EnumChatFormatting.GREEN + I18N.localise(
"botany.item.tooltip.pH",
AlleleHelper.toDisplay(primary.getHumidity()),
AlleleHelper.toDisplay(genome.getTolerancePH())));
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.fertility", genome.getFertility()));
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (nbttagcompound == null) {
genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
return;
}
@Override
public String getIdent() {
return getGenome().getPrimary().getUID();
}
age = nbttagcompound.getInteger("Age");
wilting = nbttagcompound.getBoolean("Wilt");
flowered = nbttagcompound.getBoolean("Flowered");
if (nbttagcompound.hasKey("Genome")) {
genome = new FlowerGenome(nbttagcompound.getCompoundTag("Genome"));
}
if (nbttagcompound.hasKey("Mate")) {
mate = new FlowerGenome(nbttagcompound.getCompoundTag("Mate"));
}
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (nbttagcompound == null) {
genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
return;
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("Age", age);
nbttagcompound.setBoolean("Wilt", wilting);
nbttagcompound.setBoolean("Flowered", flowered);
age = nbttagcompound.getInteger("Age");
wilting = nbttagcompound.getBoolean("Wilt");
flowered = nbttagcompound.getBoolean("Flowered");
if (nbttagcompound.hasKey("Genome")) {
genome = new FlowerGenome(nbttagcompound.getCompoundTag("Genome"));
}
if (nbttagcompound.hasKey("Mate")) {
mate = new FlowerGenome(nbttagcompound.getCompoundTag("Mate"));
}
}
if (genome != null) {
NBTTagCompound NBTmachine = new NBTTagCompound();
genome.writeToNBT(NBTmachine);
nbttagcompound.setTag("Genome", NBTmachine);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("Age", age);
nbttagcompound.setBoolean("Wilt", wilting);
nbttagcompound.setBoolean("Flowered", flowered);
if (mate != null) {
NBTTagCompound NBTmachine = new NBTTagCompound();
mate.writeToNBT(NBTmachine);
nbttagcompound.setTag("Mate", NBTmachine);
}
}
if (genome != null) {
NBTTagCompound NBTmachine = new NBTTagCompound();
genome.writeToNBT(NBTmachine);
nbttagcompound.setTag("Genome", NBTmachine);
}
public int getMetadata() {
return 0;
}
if (mate != null) {
NBTTagCompound NBTmachine = new NBTTagCompound();
mate.writeToNBT(NBTmachine);
nbttagcompound.setTag("Mate", NBTmachine);
}
}
@Override
public IFlowerGenome getGenome() {
return genome;
}
public int getMetadata() {
return 0;
}
@Override
public void mate(IFlower other) {
mate = new FlowerGenome(other.getGenome().getChromosomes());
}
@Override
public IFlowerGenome getGenome() {
return genome;
}
@Override
public IFlowerGenome getMate() {
return mate;
}
@Override
public void mate(IFlower other) {
mate = new FlowerGenome(other.getGenome().getChromosomes());
}
@Override
public IFlower copy() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound);
return new Flower(nbttagcompound);
}
@Override
public IFlowerGenome getMate() {
return mate;
}
@Override
public int getAge() {
return age;
}
@Override
public IFlower copy() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound);
return new Flower(nbttagcompound);
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public int getAge() {
return age;
}
@Override
public void age() {
if (age < 15) {
age++;
}
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public int getMaxAge() {
return getGenome().getLifespan();
}
@Override
public void age() {
if (age < 15) {
age++;
}
}
@Override
public boolean isWilted() {
return wilting;
}
@Override
public int getMaxAge() {
return getGenome().getLifespan();
}
@Override
public void setWilted(boolean value) {
wilting = value;
}
@Override
public boolean isWilted() {
return wilting;
}
@Override
public boolean hasFlowered() {
return flowered;
}
@Override
public void setWilted(boolean value) {
wilting = value;
}
@Override
public void setFlowered(boolean value) {
flowered = value;
}
@Override
public boolean hasFlowered() {
return flowered;
}
@Override
public void removeMate() {
mate = null;
}
@Override
public void setFlowered(boolean value) {
flowered = value;
}
@Override
public IFlower getOffspring(World world) {
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
IChromosome[] parent1 = mutateSpecies(world, genome, mate);
IChromosome[] parent2 = mutateSpecies(world, mate, genome);
for (int i = 0; i < parent1.length; ++i) {
if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
}
}
return new Flower(new FlowerGenome(chromosomes), 0);
}
@Override
public void removeMate() {
mate = null;
}
private IChromosome[] mutateSpecies(World world, IFlowerGenome genomeOne, IFlowerGenome genomeTwo) {
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IAllele allele0;
IAllele allele2;
IFlowerGenome genome0;
IFlowerGenome genome2;
@Override
public IFlower getOffspring(World world) {
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
IChromosome[] parent1 = mutateSpecies(world, genome, mate);
IChromosome[] parent2 = mutateSpecies(world, mate, genome);
for (int i = 0; i < parent1.length; ++i) {
if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
}
}
return new Flower(new FlowerGenome(chromosomes), 0);
}
if (world.rand.nextBoolean()) {
allele0 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeOne;
genome2 = genomeTwo;
} else {
allele0 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeTwo;
genome2 = genomeOne;
}
private IChromosome[] mutateSpecies(World world, IFlowerGenome genomeOne, IFlowerGenome genomeTwo) {
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IAllele allele0;
IAllele allele2;
IFlowerGenome genome0;
IFlowerGenome genome2;
IFlowerColor colour1 = genome0.getPrimaryColor();
IFlowerColor colour2 = genome2.getPrimaryColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
if (world.rand.nextBoolean()) {
allele0 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeOne;
genome2 = genomeTwo;
} else {
allele0 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeTwo;
genome2 = genomeOne;
}
colour1 = genome0.getSecondaryColor();
colour2 = genome2.getSecondaryColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
IFlowerColor colour1 = genome0.getPrimaryColor();
IFlowerColor colour2 = genome2.getPrimaryColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
colour1 = genome0.getStemColor();
colour2 = genome2.getStemColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
colour1 = genome0.getSecondaryColor();
colour2 = genome2.getSecondaryColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(
mutation.getResult().getAllele());
}
}
}
IChromosome[] template = null;
for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
float chance = mutation2.getChance(allele0, allele2, genome0, genome2);
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
}
}
colour1 = genome0.getStemColor();
colour2 = genome2.getStemColor();
if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
}
}
}
if (template != null) {
parent1 = template;
}
return parent1;
}
IChromosome[] template = null;
for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
float chance = mutation2.getChance(allele0, allele2, genome0, genome2);
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
}
}
if (template != null) {
parent1 = template;
}
return parent1;
}
}
@@ -1,5 +1,7 @@
package binnie.botany.genetics;
import net.minecraft.nbt.NBTTagCompound;
import binnie.Binnie;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumFlowerChromosome;
@@ -16,115 +18,113 @@ import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.Genome;
import net.minecraft.nbt.NBTTagCompound;
public class FlowerGenome extends Genome implements IFlowerGenome {
public FlowerGenome(NBTTagCompound nbttagcompound) {
super(nbttagcompound);
}
public FlowerGenome(IChromosome[] chromosomes) {
super(chromosomes);
}
public FlowerGenome(NBTTagCompound nbttagcompound) {
super(nbttagcompound);
}
@Override
public IAlleleFlowerSpecies getPrimary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele();
}
public FlowerGenome(IChromosome[] chromosomes) {
super(chromosomes);
}
@Override
public IAlleleFlowerSpecies getSecondary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele();
}
@Override
public IAlleleFlowerSpecies getPrimary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return BotanyCore.getFlowerRoot();
}
@Override
public IAlleleFlowerSpecies getSecondary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele();
}
@Override
public EnumFlowerColor getPrimaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.PRIMARY)).getColor();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return BotanyCore.getFlowerRoot();
}
@Override
public EnumFlowerColor getSecondaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.SECONDARY)).getColor();
}
@Override
public EnumFlowerColor getPrimaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.PRIMARY)).getColor();
}
@Override
public EnumFlowerColor getStemColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.STEM)).getColor();
}
@Override
public EnumFlowerColor getSecondaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.SECONDARY)).getColor();
}
@Override
public int getFertility() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue();
}
@Override
public EnumFlowerColor getStemColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.STEM)).getColor();
}
@Override
public int getLifespan() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5;
}
@Override
public int getFertility() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue();
}
@Override
public IFlowerType getType() {
return getPrimary().getType();
}
@Override
public int getLifespan() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5;
}
@Override
public EnumTolerance getToleranceTemperature() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
}
@Override
public IFlowerType getType() {
return getPrimary().getType();
}
@Override
public EnumTolerance getToleranceMoisture() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue();
}
@Override
public EnumTolerance getToleranceTemperature() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
}
@Override
public EnumTolerance getTolerancePH() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue();
}
@Override
public EnumTolerance getToleranceMoisture() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue();
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
}
@Override
public EnumTolerance getTolerancePH() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue();
}
@Override
public float getAgeChance() {
return 1.0f * (float) Math.sqrt(2.0f / getLifespan());
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
}
@Override
public float getSappiness() {
return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue();
}
@Override
public float getAgeChance() {
return (float) Math.sqrt(2.0f / getLifespan());
}
@Override
public boolean canTolerate(EnumAcidity ePH) {
int pH = ePH.ordinal();
int[] pHTol = Binnie.Genetics.getTolerance(getTolerancePH());
int fPH = getPrimary().getPH().ordinal();
return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1];
}
@Override
public float getSappiness() {
return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue();
}
@Override
public boolean canTolerate(EnumMoisture eMoisture) {
int moisture = eMoisture.ordinal();
int[] moistTol = Binnie.Genetics.getTolerance(getToleranceMoisture());
int fMoisture = getPrimary().getMoisture().ordinal();
return moisture >= fMoisture + moistTol[0]
&& moisture <= fMoisture + moistTol[1];
}
@Override
public boolean canTolerate(EnumAcidity ePH) {
int pH = ePH.ordinal();
int[] pHTol = Binnie.Genetics.getTolerance(getTolerancePH());
int fPH = getPrimary().getPH().ordinal();
return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1];
}
@Override
public boolean canTolerate(EnumTemperature eTemp) {
int temp = eTemp.ordinal();
int[] tempTol = Binnie.Genetics.getTolerance(getToleranceTemperature());
int fTemp = getPrimary().getTemperature().ordinal();
return temp >= fTemp + tempTol[0]
&& temp <= fTemp + tempTol[1];
}
@Override
public boolean canTolerate(EnumMoisture eMoisture) {
int moisture = eMoisture.ordinal();
int[] moistTol = Binnie.Genetics.getTolerance(getToleranceMoisture());
int fMoisture = getPrimary().getMoisture().ordinal();
return moisture >= fMoisture + moistTol[0] && moisture <= fMoisture + moistTol[1];
}
@Override
public boolean canTolerate(EnumTemperature eTemp) {
int temp = eTemp.ordinal();
int[] tempTol = Binnie.Genetics.getTolerance(getToleranceTemperature());
int fTemp = getPrimary().getTemperature().ordinal();
return temp >= fTemp + tempTol[0] && temp <= fTemp + tempTol[1];
}
}
@@ -1,5 +1,19 @@
package binnie.botany.genetics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.EnumFlowerStage;
@@ -10,7 +24,6 @@ import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerGenome;
import binnie.botany.api.IFlowerMutation;
import binnie.botany.api.IFlowerRoot;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosomeType;
@@ -18,257 +31,247 @@ import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesType;
import forestry.core.genetics.SpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class FlowerHelper extends SpeciesRoot implements IFlowerRoot {
public static int flowerSpeciesCount = -1;
public static ArrayList<IFlower> flowerTemplates = new ArrayList<>();
protected static String UID = "rootFlowers";
public static int flowerSpeciesCount = -1;
public static ArrayList<IFlower> flowerTemplates = new ArrayList<>();
private static ArrayList<IFlowerMutation> flowerMutations = new ArrayList<>();
private static ArrayList<IColourMix> colourMixes = new ArrayList<>();
protected static String UID = "rootFlowers";
protected Map<ItemStack, IFlower> conversions;
private static final ArrayList<IFlowerMutation> flowerMutations = new ArrayList<>();
private static final ArrayList<IColourMix> colourMixes = new ArrayList<>();
public FlowerHelper() {
conversions = new HashMap<>();
}
protected Map<ItemStack, IFlower> conversions;
@Override
public String getUID() {
return UID;
}
public FlowerHelper() {
conversions = new HashMap<>();
}
@Override
public int getSpeciesCount() {
if (FlowerHelper.flowerSpeciesCount < 0) {
FlowerHelper.flowerSpeciesCount = 0;
for (Map.Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleFlowerSpecies && ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) {
FlowerHelper.flowerSpeciesCount++;
}
}
}
return FlowerHelper.flowerSpeciesCount;
}
@Override
public String getUID() {
return UID;
}
@Override
public boolean isMember(ItemStack stack) {
return stack != null
&& getStageType(stack) != EnumFlowerStage.NONE;
}
@Override
public int getSpeciesCount() {
if (FlowerHelper.flowerSpeciesCount < 0) {
FlowerHelper.flowerSpeciesCount = 0;
for (Map.Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleFlowerSpecies
&& ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) {
FlowerHelper.flowerSpeciesCount++;
}
}
}
return FlowerHelper.flowerSpeciesCount;
}
@Override
public boolean isMember(ItemStack stack, int type) {
return getStageType(stack).ordinal() == type;
}
@Override
public boolean isMember(ItemStack stack) {
return stack != null && getStageType(stack) != EnumFlowerStage.NONE;
}
@Override
public boolean isMember(IIndividual individual) {
return individual instanceof IFlower;
}
@Override
public boolean isMember(ItemStack stack, int type) {
return getStageType(stack).ordinal() == type;
}
@Override
public ItemStack getMemberStack(IIndividual flower, int type) {
if (!isMember(flower)) {
return null;
}
@Override
public boolean isMember(IIndividual individual) {
return individual instanceof IFlower;
}
Item flowerItem = Botany.flowerItem;
if (type == EnumFlowerStage.SEED.ordinal()) {
flowerItem = Botany.seed;
}
@Override
public ItemStack getMemberStack(IIndividual flower, int type) {
if (!isMember(flower)) {
return null;
}
if (type == EnumFlowerStage.POLLEN.ordinal()) {
flowerItem = Botany.pollen;
}
Item flowerItem = Botany.flowerItem;
if (type == EnumFlowerStage.SEED.ordinal()) {
flowerItem = Botany.seed;
}
if (flowerItem != Botany.flowerItem) {
((IFlower) flower).setAge(0);
}
if (type == EnumFlowerStage.POLLEN.ordinal()) {
flowerItem = Botany.pollen;
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
flower.writeToNBT(nbttagcompound);
ItemStack flowerStack = new ItemStack(flowerItem);
flowerStack.setTagCompound(nbttagcompound);
return flowerStack;
}
if (flowerItem != Botany.flowerItem) {
((IFlower) flower).setAge(0);
}
@Override
public EnumFlowerStage getStageType(ItemStack stack) {
if (stack == null) {
return EnumFlowerStage.NONE;
}
if (stack.getItem() == Botany.flowerItem) {
return EnumFlowerStage.FLOWER;
}
if (stack.getItem() == Botany.pollen) {
return EnumFlowerStage.POLLEN;
}
if (stack.getItem() == Botany.seed) {
return EnumFlowerStage.SEED;
}
return EnumFlowerStage.NONE;
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
flower.writeToNBT(nbttagcompound);
ItemStack flowerStack = new ItemStack(flowerItem);
flowerStack.setTagCompound(nbttagcompound);
return flowerStack;
}
@Override
public IFlower getMember(ItemStack stack) {
if (!isMember(stack)) {
return null;
}
return new Flower(stack.getTagCompound());
}
@Override
public EnumFlowerStage getStageType(ItemStack stack) {
if (stack == null) {
return EnumFlowerStage.NONE;
}
if (stack.getItem() == Botany.flowerItem) {
return EnumFlowerStage.FLOWER;
}
if (stack.getItem() == Botany.pollen) {
return EnumFlowerStage.POLLEN;
}
if (stack.getItem() == Botany.seed) {
return EnumFlowerStage.SEED;
}
return EnumFlowerStage.NONE;
}
@Override
public IFlower getFlower(World world, IFlowerGenome genome) {
return new Flower(genome, 2);
}
@Override
public IFlower getMember(ItemStack stack) {
if (!isMember(stack)) {
return null;
}
return new Flower(stack.getTagCompound());
}
@Override
public IFlowerGenome templateAsGenome(IAllele[] template) {
return new FlowerGenome(templateAsChromosomes(template));
}
@Override
public IFlower getFlower(World world, IFlowerGenome genome) {
return new Flower(genome, 2);
}
@Override
public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) {
return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive));
}
@Override
public IFlowerGenome templateAsGenome(IAllele[] template) {
return new FlowerGenome(templateAsChromosomes(template));
}
@Override
public IFlower templateAsIndividual(IAllele[] template) {
return new Flower(templateAsGenome(template), 2);
}
@Override
public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) {
return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive));
}
@Override
public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) {
return new Flower(templateAsGenome(templateActive, templateInactive), 2);
}
@Override
public IFlower templateAsIndividual(IAllele[] template) {
return new Flower(templateAsGenome(template), 2);
}
@Override
public ArrayList<IFlower> getIndividualTemplates() {
return FlowerHelper.flowerTemplates;
}
@Override
public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) {
return new Flower(templateAsGenome(templateActive, templateInactive), 2);
}
@Override
public void registerTemplate(IAllele[] template) {
registerTemplate(template[0].getUID(), template);
}
@Override
public ArrayList<IFlower> getIndividualTemplates() {
return FlowerHelper.flowerTemplates;
}
@Override
public void registerTemplate(String identifier, IAllele[] template) {
FlowerHelper.flowerTemplates.add(new Flower(templateAsGenome(template), 2));
if (!speciesTemplates.containsKey(identifier)) {
speciesTemplates.put(identifier, template);
}
}
@Override
public void registerTemplate(IAllele[] template) {
registerTemplate(template[0].getUID(), template);
}
@Override
public IAllele[] getTemplate(String identifier) {
return speciesTemplates.get(identifier);
}
@Override
public void registerTemplate(String identifier, IAllele[] template) {
FlowerHelper.flowerTemplates.add(new Flower(templateAsGenome(template), 2));
if (!speciesTemplates.containsKey(identifier)) {
speciesTemplates.put(identifier, template);
}
}
@Override
public IAllele[] getDefaultTemplate() {
return FlowerTemplates.getDefaultTemplate();
}
@Override
public IAllele[] getTemplate(String identifier) {
return speciesTemplates.get(identifier);
}
@Override
public IAllele[] getRandomTemplate(Random rand) {
return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())];
}
@Override
public IAllele[] getDefaultTemplate() {
return FlowerTemplates.getDefaultTemplate();
}
@Override
public Collection<IFlowerMutation> getMutations(boolean shuffle) {
if (shuffle) {
Collections.shuffle(FlowerHelper.flowerMutations);
}
return FlowerHelper.flowerMutations;
}
@Override
public IAllele[] getRandomTemplate(Random rand) {
return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())];
}
@Override
public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()) ||
AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()) ||
AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
return;
}
FlowerHelper.flowerMutations.add((IFlowerMutation) mutation);
}
@Override
public Collection<IFlowerMutation> getMutations(boolean shuffle) {
if (shuffle) {
Collections.shuffle(FlowerHelper.flowerMutations);
}
return FlowerHelper.flowerMutations;
}
@Override
public IBotanistTracker getBreedingTracker(World world, GameProfile player) {
String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
BotanistTracker tracker = (BotanistTracker) world.loadItemData(BotanistTracker.class, filename);
if (tracker == null) {
tracker = new BotanistTracker(filename);
world.setItemData(filename, tracker);
}
return tracker;
}
@Override
public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())
|| AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())
|| AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
return;
}
FlowerHelper.flowerMutations.add((IFlowerMutation) mutation);
}
@Override
public IIndividual getMember(NBTTagCompound compound) {
return new Flower(compound);
}
@Override
public IBotanistTracker getBreedingTracker(World world, GameProfile player) {
String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
BotanistTracker tracker = (BotanistTracker) world.loadItemData(BotanistTracker.class, filename);
if (tracker == null) {
tracker = new BotanistTracker(filename);
world.setItemData(filename, tracker);
}
return tracker;
}
@Override
public Class getMemberClass() {
return IFlower.class;
}
@Override
public IIndividual getMember(NBTTagCompound compound) {
return new Flower(compound);
}
@Override
public IChromosomeType[] getKaryotype() {
return EnumFlowerChromosome.values();
}
@Override
public Class<? extends IIndividual> getMemberClass() {
return IFlower.class;
}
@Override
public IChromosomeType getKaryotypeKey() {
return EnumFlowerChromosome.SPECIES;
}
@Override
public IChromosomeType[] getKaryotype() {
return EnumFlowerChromosome.VALUES;
}
@Override
public void addConversion(ItemStack stack, IAllele[] template) {
IFlower flower = getFlower(null, templateAsGenome(template));
conversions.put(stack, flower);
}
@Override
public IChromosomeType getKaryotypeKey() {
return EnumFlowerChromosome.SPECIES;
}
@Override
public IFlower getConversion(ItemStack stack) {
for (Map.Entry<ItemStack, IFlower> entry : conversions.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return (IFlower) entry.getValue().copy();
}
}
return null;
}
@Override
public void addConversion(ItemStack stack, IAllele[] template) {
IFlower flower = getFlower(null, templateAsGenome(template));
conversions.put(stack, flower);
}
@Override
public void registerColourMix(IColourMix colorMix) {
FlowerHelper.colourMixes.add(colorMix);
}
@Override
public IFlower getConversion(ItemStack stack) {
for (Map.Entry<ItemStack, IFlower> entry : conversions.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return (IFlower) entry.getValue().copy();
}
}
return null;
}
@Override
public Collection<IColourMix> getColourMixes(boolean shuffle) {
if (shuffle) {
Collections.shuffle(FlowerHelper.colourMixes);
}
return FlowerHelper.colourMixes;
}
@Override
public void registerColourMix(IColourMix colorMix) {
FlowerHelper.colourMixes.add(colorMix);
}
// ??
@Override
public ISpeciesType getType(ItemStack stack) {
return null;
}
@Override
public Collection<IColourMix> getColourMixes(boolean shuffle) {
if (shuffle) {
Collections.shuffle(FlowerHelper.colourMixes);
}
return FlowerHelper.colourMixes;
}
// ??
@Override
public ISpeciesType getType(ItemStack stack) {
return null;
}
}
@@ -1,5 +1,8 @@
package binnie.botany.genetics;
import java.util.ArrayList;
import java.util.Collection;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlowerMutation;
import binnie.botany.core.BotanyCore;
@@ -7,79 +10,76 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.ISpeciesRoot;
import java.util.ArrayList;
import java.util.Collection;
public class FlowerMutation implements IFlowerMutation {
protected IAlleleFlowerSpecies allele0;
protected IAlleleFlowerSpecies allele1;
protected IAllele[] template;
protected int chance;
FlowerMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] template, int chance) {
this.allele0 = allele0;
this.allele1 = allele1;
this.template = template;
this.chance = chance;
}
protected IAlleleFlowerSpecies allele0;
protected IAlleleFlowerSpecies allele1;
protected IAllele[] template;
protected int chance;
@Override
public IAlleleFlowerSpecies getAllele0() {
return allele0;
}
FlowerMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] template, int chance) {
this.allele0 = allele0;
this.allele1 = allele1;
this.template = template;
this.chance = chance;
}
@Override
public IAlleleFlowerSpecies getAllele1() {
return allele1;
}
@Override
public IAlleleFlowerSpecies getAllele0() {
return allele0;
}
@Override
public IAllele[] getTemplate() {
return template;
}
@Override
public IAlleleFlowerSpecies getAllele1() {
return allele1;
}
@Override
public float getBaseChance() {
return chance;
}
@Override
public IAllele[] getTemplate() {
return template;
}
@Override
public boolean isPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID())
|| allele.getUID().equals(allele1.getUID());
}
@Override
public float getBaseChance() {
return chance;
}
@Override
public IAllele getPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID()) ? allele1 : allele0;
}
@Override
public boolean isPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID()) || allele.getUID().equals(allele1.getUID());
}
@Override
public boolean isSecret() {
return false;
}
@Override
public IAllele getPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID()) ? allele1 : allele0;
}
@Override
public float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
if (allele0 == null || allele1 == null) {
return 0.0f;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return getBaseChance();
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return getBaseChance();
}
return 0.0f;
}
@Override
public boolean isSecret() {
return false;
}
@Override
public ISpeciesRoot getRoot() {
return BotanyCore.getFlowerRoot();
}
@Override
public float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
if (allele0 == null || allele1 == null) {
return 0.0f;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return getBaseChance();
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return getBaseChance();
}
return 0.0f;
}
@Override
public Collection<String> getSpecialConditions() {
return new ArrayList<>();
}
@Override
public ISpeciesRoot getRoot() {
return BotanyCore.getFlowerRoot();
}
@Override
public Collection<String> getSpecialConditions() {
return new ArrayList<>();
}
}
File diff suppressed because it is too large. Load diff
@@ -7,20 +7,21 @@ import forestry.api.genetics.IAllele;
import forestry.core.genetics.alleles.EnumAllele;
public class FlowerTemplates {
public static IAllele[] getDefaultTemplate() {
IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
alleles[EnumFlowerChromosome.SPECIES.ordinal()] = FlowerSpecies.POPPY;
alleles[EnumFlowerChromosome.PRIMARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.SECONDARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.FERTILITY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Fertility.NORMAL);
alleles[EnumFlowerChromosome.TERRITORY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Territory.AVERAGE);
alleles[EnumFlowerChromosome.EFFECT.ordinal()] = ModuleGenetics.alleleEffectNone;
alleles[EnumFlowerChromosome.LIFESPAN.ordinal()] = AlleleHelper.getAllele(EnumAllele.Lifespan.NORMAL);
alleles[EnumFlowerChromosome.TEMPERATURE_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.HUMIDITY_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.PH_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.SAPPINESS.ordinal()] = AlleleHelper.getAllele(EnumAllele.Sappiness.AVERAGE);
alleles[EnumFlowerChromosome.STEM.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.GREEN);
return alleles;
}
public static IAllele[] getDefaultTemplate() {
IAllele[] alleles = new IAllele[EnumFlowerChromosome.VALUES.length];
alleles[EnumFlowerChromosome.SPECIES.ordinal()] = FlowerSpecies.POPPY;
alleles[EnumFlowerChromosome.PRIMARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.SECONDARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.FERTILITY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Fertility.NORMAL);
alleles[EnumFlowerChromosome.TERRITORY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Territory.AVERAGE);
alleles[EnumFlowerChromosome.EFFECT.ordinal()] = ModuleGenetics.alleleEffectNone;
alleles[EnumFlowerChromosome.LIFESPAN.ordinal()] = AlleleHelper.getAllele(EnumAllele.Lifespan.NORMAL);
alleles[EnumFlowerChromosome.TEMPERATURE_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.HUMIDITY_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.PH_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.SAPPINESS.ordinal()] = AlleleHelper.getAllele(EnumAllele.Sappiness.AVERAGE);
alleles[EnumFlowerChromosome.STEM.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.GREEN);
return alleles;
}
}
@@ -1,11 +1,9 @@
package binnie.botany.genetics;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.core.BotanyGUI;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -14,54 +12,61 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.core.BotanyGUI;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemDictionary extends Item {
protected IIcon iconMaster;
public ItemDictionary() {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("database");
setMaxStackSize(1);
}
protected IIcon iconMaster;
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "botanistDatabase");
iconMaster = Botany.proxy.getIcon(register, "masterBotanistDatabase");
}
public ItemDictionary() {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("database");
setMaxStackSize(1);
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return (damage == 0) ? itemIcon : iconMaster;
}
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "botanistDatabase");
iconMaster = Botany.proxy.getIcon(register, "masterBotanistDatabase");
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
super.getSubItems(item, tab, list);
list.add(new ItemStack(item, 1, 1));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return (damage == 0) ? itemIcon : iconMaster;
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BotanyGUI guiId = (stack.getItemDamage() == 0) ? BotanyGUI.Database : BotanyGUI.DatabaseNEI;
Botany.proxy.openGui(guiId, player, (int) player.posX, (int) player.posY, (int) player.posZ);
return stack;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return (stack.getItemDamage() == 0)
? I18N.localise("botany.item.database.0.name")
: I18N.localise("botany.item.database.1.name");
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
super.getSubItems(item, tab, list);
list.add(new ItemStack(item, 1, 1));
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BotanyGUI guiId = (stack.getItemDamage() == 0) ? BotanyGUI.Database : BotanyGUI.DatabaseNEI;
Botany.proxy.openGui(guiId, player, (int) player.posX, (int) player.posY, (int) player.posZ);
return stack;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return (stack.getItemDamage() == 0) ? I18N.localise("botany.item.database.0.name")
: I18N.localise("botany.item.database.1.name");
}
}
@@ -1,5 +1,9 @@
package binnie.botany.genetics;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.core.BotanyCore;
@@ -17,61 +21,66 @@ import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.recipes.RecipeManagers;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public class ModuleGenetics implements IInitializable {
static AlleleEffectNone alleleEffectNone = new AlleleEffectNone();
@Override
public void preInit() {
EnumFlowerColor.setupMutations();
Botany.flower = new BlockFlower();
Botany.flowerItem = new ItemFlower();
Botany.pollen = new ItemPollen();
Botany.seed = new ItemSeed();
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.speciesRoot);
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
GameRegistry.registerBlock(Botany.flower, "flower");
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
Botany.database = new ItemDictionary();
}
static AlleleEffectNone alleleEffectNone = new AlleleEffectNone();
@Override
public void init() {
for (EnumFlowerColor color : EnumFlowerColor.values()) {
AlleleManager.alleleRegistry.registerAllele(color.getAllele());
}
@Override
public void preInit() {
EnumFlowerColor.setupMutations();
Botany.flower = new BlockFlower();
Botany.flowerItem = new ItemFlower();
Botany.pollen = new ItemPollen();
Botany.seed = new ItemSeed();
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.speciesRoot);
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
GameRegistry.registerBlock(Botany.flower, "flower");
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
Botany.database = new ItemDictionary();
}
FlowerSpecies.setupVariants();
for (FlowerSpecies species : FlowerSpecies.values()) {
AlleleManager.alleleRegistry.registerAllele(species);
BotanyCore.getFlowerRoot().registerTemplate(species.getUID(), species.getTemplate());
for (IAllele[] variant : species.getVariants()) {
BotanyCore.getFlowerRoot().registerTemplate(variant);
}
}
@Override
public void init() {
for (EnumFlowerColor color : EnumFlowerColor.VALUES) {
AlleleManager.alleleRegistry.registerAllele(color.getAllele());
}
RendererBotany.renderID = RenderingRegistry.getNextAvailableRenderId();
BinnieCore.proxy.registerBlockRenderer(new RendererBotany());
}
FlowerSpecies.setupVariants();
for (FlowerSpecies species : FlowerSpecies.values()) {
AlleleManager.alleleRegistry.registerAllele(species);
BotanyCore.getFlowerRoot().registerTemplate(species.getUID(), species.getTemplate());
for (IAllele[] variant : species.getVariants()) {
BotanyCore.getFlowerRoot().registerTemplate(variant);
}
}
@Override
public void postInit() {
FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
RecipeManagers.carpenterManager.addRecipe(
100,
Binnie.Liquid.getLiquidStack("water", 2000),
null,
new ItemStack(Botany.database),
"X#X", "YEY", "RDR",
'#', Blocks.glass_pane,
'X', Items.gold_ingot,
'Y', Items.gold_nugget,
'R', Items.redstone,
'D', Items.diamond,
'E', Items.emerald
);
}
RendererBotany.renderID = RenderingRegistry.getNextAvailableRenderId();
BinnieCore.proxy.registerBlockRenderer(new RendererBotany());
}
@Override
public void postInit() {
FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
RecipeManagers.carpenterManager.addRecipe(
100,
Binnie.Liquid.getLiquidStack("water", 2000),
null,
new ItemStack(Botany.database),
"X#X",
"YEY",
"RDR",
'#',
Blocks.glass_pane,
'X',
Items.gold_ingot,
'Y',
Items.gold_nugget,
'R',
Items.redstone,
'D',
Items.diamond,
'E',
Items.emerald);
}
}
@@ -1,60 +1,62 @@
package binnie.botany.items;
import binnie.botany.Botany;
import binnie.core.item.IItemMisc;
import binnie.core.util.I18N;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
import binnie.botany.Botany;
import binnie.core.item.IItemMisc;
import binnie.core.util.I18N;
public enum BotanyItems implements IItemMisc {
AshPowder("powderAsh"),
PulpPowder("powderPulp"),
MulchPowder("powderMulch"),
SulphurPowder("powderSulphur"),
FertiliserPowder("powderFertiliser"),
CompostPowder("powderCompost"),
Mortar("mortar"),
Weedkiller("weedkiller");
protected IIcon icon;
protected String name;
protected String iconPath;
AshPowder("powderAsh"),
PulpPowder("powderPulp"),
MulchPowder("powderMulch"),
SulphurPowder("powderSulphur"),
FertiliserPowder("powderFertiliser"),
CompostPowder("powderCompost"),
Mortar("mortar"),
Weedkiller("weedkiller");
BotanyItems(String name) {
this.name = name;
this.iconPath = name;
}
private IIcon icon;
private final String name;
private final String iconPath;
@Override
public IIcon getIcon(ItemStack itemStack) {
return icon;
}
BotanyItems(String name) {
this.name = name;
this.iconPath = name;
}
@Override
public void registerIcons(IIconRegister register) {
icon = Botany.proxy.getIcon(register, iconPath);
}
@Override
public IIcon getIcon(ItemStack itemStack) {
return icon;
}
@Override
public void addInformation(List data) {
// ignored
}
@Override
public void registerIcons(IIconRegister register) {
icon = Botany.proxy.getIcon(register, iconPath);
}
@Override
public String getName(ItemStack itemStack) {
return I18N.localise("botany.item." + name + ".name");
}
@Override
public void addInformation(List<String> data) {
// ignored
}
@Override
public ItemStack get(int count) {
return new ItemStack(Botany.misc, count, ordinal());
}
@Override
public String getName(ItemStack itemStack) {
return I18N.localise("botany.item." + name + ".name");
}
@Override
public boolean isActive() {
return true;
}
@Override
public ItemStack get(int count) {
return new ItemStack(Botany.misc, count, ordinal());
}
@Override
public boolean isActive() {
return true;
}
}
+45 -39
View File
@@ -1,11 +1,9 @@
package binnie.botany.items;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,44 +11,52 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import java.util.List;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemClay extends Item {
public ItemClay() {
setUnlocalizedName("clay");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
public ItemClay() {
setUnlocalizedName("clay");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false);
}
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.clay.name");
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "clay");
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.clay.name");
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "clay");
}
}
@@ -1,11 +1,9 @@
package binnie.botany.items;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,44 +11,52 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import java.util.List;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemPigment extends Item {
public ItemPigment() {
setUnlocalizedName("pigment");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
public ItemPigment() {
setUnlocalizedName("pigment");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false);
}
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.pigment.name");
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "pigment");
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.pigment.name");
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "pigment");
}
}
@@ -1,5 +1,7 @@
package binnie.botany.network;
import java.io.IOException;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.genetics.EnumFlowerType;
@@ -7,44 +9,43 @@ import binnie.core.network.packet.MessageBinnie;
import binnie.core.network.packet.MessageCoordinates;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
public class MessageFlowerUpdate extends MessageCoordinates {
public TileEntityFlower.RenderInfo render;
public MessageFlowerUpdate(int posX, int posY, int posZ, TileEntityFlower.RenderInfo render) {
super(PacketID.FlowerUpdate.ordinal(), posX, posY, posZ);
this.render = render;
}
public TileEntityFlower.RenderInfo render;
public MessageFlowerUpdate(MessageBinnie message) {
super(message);
}
public MessageFlowerUpdate(int posX, int posY, int posZ, TileEntityFlower.RenderInfo render) {
super(PacketID.FlowerUpdate.ordinal(), posX, posY, posZ);
this.render = render;
}
@Override
public void writeData(ByteBuf data) throws IOException {
super.writeData(data);
data.writeByte(render.primary.getID());
data.writeByte(render.secondary.getID());
data.writeByte(render.stem.getID());
data.writeByte(render.type.ordinal());
data.writeByte(render.age);
data.writeByte(render.section);
data.writeBoolean(render.wilted);
data.writeBoolean(render.flowered);
}
public MessageFlowerUpdate(MessageBinnie message) {
super(message);
}
@Override
public void readData(ByteBuf data) throws IOException {
super.readData(data);
render = new TileEntityFlower.RenderInfo();
render.primary = EnumFlowerColor.values()[data.readByte()];
render.secondary = EnumFlowerColor.values()[data.readByte()];
render.stem = EnumFlowerColor.values()[data.readByte()];
render.type = EnumFlowerType.values()[data.readByte()];
render.age = data.readByte();
render.section = data.readByte();
render.wilted = data.readBoolean();
render.flowered = data.readBoolean();
}
@Override
public void writeData(ByteBuf data) throws IOException {
super.writeData(data);
data.writeByte(render.primary.getID());
data.writeByte(render.secondary.getID());
data.writeByte(render.stem.getID());
data.writeByte(render.type.ordinal());
data.writeByte(render.age);
data.writeByte(render.section);
data.writeBoolean(render.wilted);
data.writeBoolean(render.flowered);
}
@Override
public void readData(ByteBuf data) throws IOException {
super.readData(data);
render = new TileEntityFlower.RenderInfo();
render.primary = EnumFlowerColor.get(data.readByte());
render.secondary = EnumFlowerColor.get(data.readByte());
render.stem = EnumFlowerColor.get(data.readByte());
render.type = EnumFlowerType.VALUES[data.readByte()];
render.age = data.readByte();
render.section = data.readByte();
render.wilted = data.readBoolean();
render.flowered = data.readBoolean();
}
}
@@ -1,5 +1,11 @@
package binnie.botany.network;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.genetics.EnumFlowerColor;
@@ -10,81 +16,79 @@ import binnie.core.network.packet.MessageNBT;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import forestry.api.genetics.AlleleManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
public enum PacketID implements IPacketID {
FieldKit,
FlowerUpdate;
@Override
public void onMessage(MessageBinnie message, MessageContext context) {
if (this == PacketID.FieldKit && context.side == Side.CLIENT) {
onFieldKitPacket(message);
} else if (this == PacketID.FlowerUpdate) {
onFlowerUpdatePacket(message);
}
}
FieldKit,
FlowerUpdate;
private void onFlowerUpdatePacket(MessageBinnie message) {
MessageFlowerUpdate packet = new MessageFlowerUpdate(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).setRender(packet.render);
}
}
@Override
public void onMessage(MessageBinnie message, MessageContext context) {
if (this == PacketID.FieldKit && context.side == Side.CLIENT) {
onFieldKitPacket(message);
} else if (this == PacketID.FlowerUpdate) {
onFlowerUpdatePacket(message);
}
}
private void onFieldKitPacket(MessageBinnie message) {
MessageNBT packet = new MessageNBT(message);
NBTTagCompound data = packet.getTagCompound();
EntityPlayer player = BinnieCore.proxy.getPlayer();
String info = "";
if (data.hasNoTags()) {
info += "Flower has not been discovered by you. Breed this flower yourself to discover.";
} else {
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species"));
IAlleleFlowerSpecies secondary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species2"));
float age = data.getFloat("Age");
EnumFlowerColor color1 = EnumFlowerColor.get(data.getShort("Colour"));
EnumFlowerColor color2 = EnumFlowerColor.get(data.getShort("Colour2"));
if (primary == null || secondary == null) {
return;
}
private void onFlowerUpdatePacket(MessageBinnie message) {
MessageFlowerUpdate packet = new MessageFlowerUpdate(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).setRender(packet.render);
}
}
info += "A";
if (age == 0.0f) {
info += "";
} else if (age < 0.25f) {
info += " Young";
} else if (age < 0.75f) {
info += " Mature";
} else {
info += " Old";
}
private void onFieldKitPacket(MessageBinnie message) {
MessageNBT packet = new MessageNBT(message);
NBTTagCompound data = packet.getTagCompound();
EntityPlayer player = BinnieCore.proxy.getPlayer();
String info = "";
if (data.hasNoTags()) {
info += "Flower has not been discovered by you. Breed this flower yourself to discover.";
} else {
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry
.getAllele(data.getString("Species"));
IAlleleFlowerSpecies secondary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry
.getAllele(data.getString("Species2"));
float age = data.getFloat("Age");
EnumFlowerColor color1 = EnumFlowerColor.get(data.getShort("Colour"));
EnumFlowerColor color2 = EnumFlowerColor.get(data.getShort("Colour2"));
if (primary == null || secondary == null) {
return;
}
if (color1 == color2) {
info = info + " " + color1.getName();
} else {
info = info + " " + color1.getName() + " & " + color2.getName();
}
info += "A";
if (age == 0.0f) {
info += "";
} else if (age < 0.25f) {
info += " Young";
} else if (age < 0.75f) {
info += " Mature";
} else {
info += " Old";
}
if (primary == secondary) {
info = info + " " + primary.getName();
} else {
info = info + " " + primary.getName() + "-" + secondary.getName() + " Hybrid";
}
if (color1 == color2) {
info = info + " " + color1.getName();
} else {
info = info + " " + color1.getName() + " & " + color2.getName();
}
if (age == 0.0f) {
info += " Germling";
}
if (data.getBoolean("Wilting")) {
info += ". Shame it is Wilting!";
}
}
IChatComponent chat = new ChatComponentText(info);
player.addChatMessage(chat);
}
if (primary == secondary) {
info = info + " " + primary.getName();
} else {
info = info + " " + primary.getName() + "-" + secondary.getName() + " Hybrid";
}
if (age == 0.0f) {
info += " Germling";
}
if (data.getBoolean("Wilting")) {
info += ". Shame it is Wilting!";
}
}
IChatComponent chat = new ChatComponentText(info);
player.addChatMessage(chat);
}
}
+4 -3
View File
@@ -4,7 +4,8 @@ import binnie.botany.Botany;
import binnie.core.proxy.BinnieModProxy;
public class Proxy extends BinnieModProxy implements IBotanyProxy {
public Proxy() {
super(Botany.instance);
}
public Proxy() {
super(Botany.instance);
}
}
+64 -112
View File
@@ -1,8 +1,9 @@
package binnie.core;
import binnie.Binnie;
import java.util.ArrayList;
import java.util.List;
import binnie.core.gui.IBinnieGUID;
import binnie.core.mod.parser.FieldParser;
import binnie.core.network.BinniePacketHandler;
import binnie.core.network.IPacketID;
import binnie.core.network.IPacketProvider;
@@ -11,133 +12,84 @@ import binnie.core.proxy.IProxyCore;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.MinecraftForge;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
public abstract class AbstractMod implements IPacketProvider, IInitializable {
private SimpleNetworkWrapper wrapper;
private final LinkedHashSet<Field> fields;
protected final List<IInitializable> modules;
public AbstractMod() {
fields = new LinkedHashSet<>();
modules = new ArrayList<>();
BinnieCore.registerMod(this);
MinecraftForge.EVENT_BUS.register(this);
}
private SimpleNetworkWrapper wrapper;
protected final List<IInitializable> modules;
public abstract boolean isActive();
public AbstractMod() {
modules = new ArrayList<>();
BinnieCore.registerMod(this);
}
@Override
public abstract String getChannel();
public boolean isActive() {
return true;
}
@Override
public IPacketID[] getPacketIDs() {
return new IPacketID[0];
}
@Override
public abstract String getChannel();
public IBinnieGUID[] getGUIDs() {
return new IBinnieGUID[0];
}
@Override
public IPacketID[] getPacketIDs() {
return new IPacketID[0];
}
public Class[] getConfigs() {
return new Class[0];
}
public IBinnieGUID[] getGUIDs() {
return new IBinnieGUID[0];
}
public abstract IProxyCore getProxy();
public abstract IProxyCore getProxy();
public abstract String getModID();
public abstract String getModID();
public SimpleNetworkWrapper getNetworkWrapper() {
return wrapper;
}
public SimpleNetworkWrapper getNetworkWrapper() {
return wrapper;
}
protected abstract Class<? extends BinniePacketHandler> getPacketHandler();
protected abstract Class<? extends BinniePacketHandler> getPacketHandler();
@Override
public void preInit() {
if (!isActive()) {
return;
}
@Override
public void preInit() {
if (!isActive()) {
return;
}
if (getConfigs() != null) {
for (Class cls : getConfigs()) {
Binnie.Configuration.registerConfiguration(cls, this);
}
}
getProxy().preInit();
for (IInitializable module : modules) {
module.preInit();
}
}
getProxy().preInit();
for (IInitializable module : modules) {
module.preInit();
}
// TODO what does it mean?
Collections.addAll(fields, getClass().getFields());
for (Class cls : getClass().getClasses()) {
Collections.addAll(fields, getClass().getFields());
}
for (IInitializable module : modules) {
Collections.addAll(fields, module.getClass().getFields());
}
for (Field field4 : fields) {
try {
FieldParser.preInitParse(field4, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
public void init() {
if (!isActive()) {
return;
}
getProxy().init();
@Override
public void init() {
if (!isActive()) {
return;
}
getProxy().init();
wrapper = NetworkRegistry.INSTANCE.newSimpleChannel(getChannel());
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.CLIENT);
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.SERVER);
for (IInitializable module : modules) {
module.init();
}
}
wrapper = NetworkRegistry.INSTANCE.newSimpleChannel(getChannel());
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.CLIENT);
wrapper.registerMessage(getPacketHandler(), MessageBinnie.class, 1, Side.SERVER);
for (IInitializable module : modules) {
module.init();
}
@Override
public void postInit() {
if (!isActive()) {
return;
}
for (Field field : fields) {
try {
FieldParser.initParse(field, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
getProxy().postInit();
for (IInitializable module : modules) {
module.postInit();
}
}
@Override
public void postInit() {
if (!isActive()) {
return;
}
getProxy().postInit();
for (IInitializable module : modules) {
module.postInit();
}
for (Field field : fields) {
try {
FieldParser.postInitParse(field, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
protected void addModule(IInitializable init) {
modules.add(init);
MinecraftForge.EVENT_BUS.register(init);
}
protected void addModule(IInitializable init) {
modules.add(init);
init.registerEventHandler();
}
}
+164 -164
View File
@@ -1,8 +1,18 @@
package binnie.core;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import binnie.Binnie;
import binnie.core.block.MultipassBlockRenderer;
import binnie.core.block.TileEntityMetadata;
import binnie.core.config.BCConfig;
import binnie.core.craftgui.minecraft.ModuleCraftGUI;
import binnie.core.gui.BinnieCoreGUI;
import binnie.core.gui.BinnieGUIHandler;
@@ -13,10 +23,6 @@ import binnie.core.liquid.FluidContainer;
import binnie.core.liquid.ItemFluidContainer;
import binnie.core.machines.MachineGroup;
import binnie.core.machines.storage.ModuleStorage;
import binnie.core.mod.config.ConfigurationMain;
import binnie.core.mod.config.ConfigurationMods;
import binnie.core.mod.parser.FieldParser;
import binnie.core.mod.parser.ItemParser;
import binnie.core.network.BinnieCorePacketID;
import binnie.core.network.BinniePacketHandler;
import binnie.core.network.IPacketID;
@@ -38,194 +44,188 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.ForestryEvent;
import forestry.plugins.PluginManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.TextureStitchEvent;
import java.util.ArrayList;
import java.util.List;
import static binnie.core.BinnieCore.*;
@Mod(modid = "BinnieCore", name = "Binnie Core", version = VERSION, useMetadata = true, dependencies = "after:Forestry@[4.2,)")
@Mod(
modid = BinnieCore.CORE_MODID,
name = BinnieCore.CORE_MOD_NAME,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)")
public class BinnieCore extends AbstractMod {
@Mod.Instance("BinnieCore")
public static BinnieCore instance;
@SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer")
public static BinnieProxy proxy;
public static int multipassRenderID;
private static List<AbstractMod> modList = new ArrayList<>();
public static MachineGroup packageCompartment;
public static ItemGenesis genesis;
public static ItemFieldKit fieldKit;
public static final String VERSION = "GRADLETOKEN_VERSION";
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
for (ManagerBase baseManager : Binnie.Managers) {
addModule(baseManager);
}
public static final String CORE_MODID = "BinnieCore";
public static final String CORE_MOD_NAME = "Binnie Core";
addModule(new ModuleCraftGUI());
addModule(new ModuleStorage());
addModule(new ModuleItems());
if (Loader.isModLoaded("BuildCraft|Silicon")) {
addModule(new ModuleTrigger());
}
preInit();
}
@Mod.Instance("BinnieCore")
public static BinnieCore instance;
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
init();
}
@SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer")
public static BinnieProxy proxy;
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) {
postInit();
}
public static int multipassRenderID;
private static final List<AbstractMod> modList = new ArrayList<>();
public static MachineGroup packageCompartment;
public static ItemGenesis genesis;
public static ItemFieldKit fieldKit;
@Override
public IBinnieGUID[] getGUIDs() {
return BinnieCoreGUI.values();
}
public BinnieCore() {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public void preInit() {
instance = this;
for (FluidContainer container : FluidContainer.values()) {
Item item = new ItemFluidContainer(container);
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
}
FieldParser.parsers.add(new ItemParser());
super.preInit();
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
for (ManagerBase baseManager : Binnie.Managers) {
addModule(baseManager);
}
@Override
public void init() {
super.init();
for (AbstractMod mod : getActiveMods()) {
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod));
}
addModule(new ModuleCraftGUI());
if (!BCConfig.disableCompartments) {
addModule(new ModuleStorage());
}
addModule(new ModuleItems());
if (Loader.isModLoaded("BuildCraft|Silicon")) {
addModule(new ModuleTrigger());
}
preInit();
}
multipassRenderID = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer());
GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata");
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
init();
}
public static boolean isLepidopteryActive() {
return PluginManager.Module.LEPIDOPTEROLOGY.isEnabled();
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
postInit();
}
public static boolean isApicultureActive() {
return PluginManager.Module.APICULTURE.isEnabled();
}
@Override
public IBinnieGUID[] getGUIDs() {
return BinnieCoreGUI.values();
}
public static boolean isArboricultureActive() {
return PluginManager.Module.ARBORICULTURE.isEnabled();
}
@Override
public void preInit() {
instance = this;
for (FluidContainer container : FluidContainer.values()) {
Item item = new ItemFluidContainer(container);
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
}
super.preInit();
}
public static boolean isBotanyActive() {
return ConfigurationMods.botany;
}
@Override
public void init() {
super.init();
for (AbstractMod mod : getActiveMods()) {
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod));
}
public static boolean isGeneticsActive() {
return ConfigurationMods.genetics;
}
multipassRenderID = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer());
GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata");
}
public static boolean isExtraBeesActive() {
return ConfigurationMods.extraBees && isApicultureActive();
}
public static boolean isLepidopteryActive() {
return PluginManager.Module.LEPIDOPTEROLOGY.isEnabled();
}
public static boolean isExtraTreesActive() {
return ConfigurationMods.extraTrees && isArboricultureActive();
}
public static boolean isApicultureActive() {
return PluginManager.Module.APICULTURE.isEnabled();
}
@Override
public void postInit() {
super.postInit();
}
public static boolean isArboricultureActive() {
return PluginManager.Module.ARBORICULTURE.isEnabled();
}
static void registerMod(AbstractMod mod) {
modList.add(mod);
}
public static boolean isExtraBeesActive() {
return isApicultureActive();
}
private static List<AbstractMod> getActiveMods() {
List<AbstractMod> list = new ArrayList<>();
for (AbstractMod mod : modList) {
if (mod.isActive()) {
list.add(mod);
}
}
return list;
}
public static boolean isExtraTreesActive() {
return isArboricultureActive();
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
try {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.username.getName());
if (player == null) {
return;
}
event.tracker.synchToPlayer(player);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("species", event.species.getUID());
} catch (Exception ex) {
// ignored
}
}
@Override
public void postInit() {
super.postInit();
}
@Override
public String getChannel() {
return "BIN";
}
static void registerMod(AbstractMod mod) {
modList.add(mod);
}
@Override
public IBinnieProxy getProxy() {
return proxy;
}
private static List<AbstractMod> getActiveMods() {
List<AbstractMod> list = new ArrayList<>();
for (AbstractMod mod : modList) {
if (mod.isActive()) {
list.add(mod);
}
}
return list;
}
@Override
public String getModID() {
return "binniecore";
}
@Override
public String getChannel() {
return "BIN";
}
@Override
public IPacketID[] getPacketIDs() {
return BinnieCorePacketID.values();
}
@Override
public IBinnieProxy getProxy() {
return proxy;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTextureRemap(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
Binnie.Liquid.reloadIcons(event.map);
}
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
}
@Override
public String getModID() {
return "binniecore";
}
@Override
public Class<?>[] getConfigs() {
return new Class[]{ConfigurationMain.class};
}
@Override
public IPacketID[] getPacketIDs() {
return BinnieCorePacketID.values();
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
}
@Override
public boolean isActive() {
return true;
}
@Override
public boolean isActive() {
return true;
}
public static class PacketHandler extends BinniePacketHandler {
public PacketHandler() {
super(instance);
}
}
public static class PacketHandler extends BinniePacketHandler {
public PacketHandler() {
super(instance);
}
}
public static class EventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
try {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager()
.func_152612_a(event.username.getName());
if (player == null) {
return;
}
event.tracker.synchToPlayer(player);
} catch (Exception ex) {
// ignored
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTextureRemap(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
Binnie.Liquid.reloadIcons(event.map);
}
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
}
}
}
@@ -1,9 +1,12 @@
package binnie.core;
public interface IInitializable {
void preInit();
void init();
void preInit();
void postInit();
void init();
void postInit();
default void registerEventHandler() {}
}
+16 -15
View File
@@ -3,22 +3,23 @@ package binnie.core;
import binnie.Binnie;
public abstract class ManagerBase implements IInitializable {
public ManagerBase() {
Binnie.Managers.add(this);
}
@Override
public void preInit() {
// ignored
}
public ManagerBase() {
Binnie.Managers.add(this);
}
@Override
public void init() {
// ignored
}
@Override
public void preInit() {
// ignored
}
@Override
public void postInit() {
// ignored
}
@Override
public void init() {
// ignored
}
@Override
public void postInit() {
// ignored
}
}
Loaded 100 of 2708 files, more files were not shown because too many files have changed in this diff. Show more