mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-15 01:35:08 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2a49158f3 | ||
|
|
cb81d0ead4 | ||
|
|
21728bcab1 | ||
|
|
dbdb5478c2 | ||
|
|
46c5b95d82 | ||
|
|
e6547caacc | ||
|
|
f7b1805e95 | ||
|
|
123b47f038 | ||
|
|
c96ab68f19 | ||
|
|
35d6304a96 | ||
|
|
8f69af62f8 | ||
|
|
d2b14b6320 | ||
|
|
65431e73d4 | ||
|
|
fa4a5b0a17 | ||
|
|
714ba830d7 | ||
|
|
ed3cfe12a1 | ||
|
|
d2a9e62cb2 | ||
|
|
cbfb25647a | ||
|
|
6587200dd3 | ||
|
|
b488570a5f | ||
|
|
40a1c94a86 | ||
|
|
79c303b12d | ||
|
|
065d795622 | ||
|
|
2b54db9342 | ||
|
|
8f8e497f58 | ||
|
|
34fda5ddd1 | ||
|
|
ab1a2eeb89 | ||
|
|
5c40de2eba | ||
|
|
b0503fe523 | ||
|
|
3e3c9c30a4 | ||
|
|
1b338efca9 | ||
|
|
ddc9764a23 | ||
|
|
f23e28deaf | ||
|
|
afb9a62686 | ||
|
|
79a49341e9 | ||
|
|
5a93a3d0a9 | ||
|
|
2afb3c52f3 | ||
|
|
cbe86e814f | ||
|
|
c5f2368e1d | ||
|
|
7e4e518d7b | ||
|
|
21aa0c43a6 | ||
|
|
724c3d1fbd | ||
|
|
6c3d7d3bb0 | ||
|
|
afb9460ff9 | ||
|
|
687c440c69 | ||
|
|
1b722df37a | ||
|
|
dcdf4b1cac | ||
|
|
705581b9ac | ||
|
|
2a451bc72e | ||
|
|
faf2b88ed8 | ||
|
|
fcef87b3da | ||
|
|
fcbbd06c63 | ||
|
|
1b3b452900 | ||
|
|
0726954433 | ||
|
|
6ff11f4eea | ||
|
|
03eaa2510c | ||
|
|
a3103bce5e | ||
|
|
a9030ef60b | ||
|
|
4062adee6c | ||
|
|
2ca2cef6a2 | ||
|
|
95dca83465 | ||
|
|
f977a29ad6 | ||
|
|
68ed8a1511 | ||
|
|
c9d3001b47 | ||
|
|
75c875868a | ||
|
|
c51a9273f9 | ||
|
|
4edd2e9d5d | ||
|
|
bc310023df | ||
|
|
703e99e916 | ||
|
|
f73667c173 | ||
|
|
0101eae8f8 | ||
|
|
5be32a2a3a | ||
|
|
3ff4957a10 | ||
|
|
9e1ec59b86 | ||
|
|
0aa9853da2 | ||
|
|
96fe27e834 | ||
|
|
934bb3b8f9 | ||
|
|
83d9da7797 | ||
|
|
1e0d11b1ac | ||
|
|
808b04c3b8 | ||
|
|
2425ae959e | ||
|
|
3679551882 | ||
|
|
83fd00cad5 | ||
|
|
f3d93b47b9 | ||
|
|
62fc457808 | ||
|
|
2811aabc2e | ||
|
|
8573f087eb | ||
|
|
d0215ce0aa | ||
|
|
b6d5901f07 | ||
|
|
18f30c8c0d | ||
|
|
cf8634546c | ||
|
|
864e5e0dfc | ||
|
|
6df4570bca | ||
|
|
e0d23ada41 | ||
|
|
b7b663640d | ||
|
|
9989eef753 | ||
|
|
941c377c58 | ||
|
|
be827a17a7 | ||
|
|
beb1ba9ae1 | ||
|
|
709d80adc6 | ||
|
|
552a907d58 | ||
|
|
e0409c17ba | ||
|
|
b1de19e1f1 | ||
|
|
09754111f0 | ||
|
|
a7da3c5297 | ||
|
|
866e8d0711 | ||
|
|
bbc87beb38 | ||
|
|
d0cb769a2b | ||
|
|
d678903d68 | ||
|
|
140df9ce4e | ||
|
|
db2f4b7360 | ||
|
|
b9dfb8ee31 | ||
|
|
a408df86ed | ||
|
|
564f586c58 | ||
|
|
05308e82c8 | ||
|
|
e9d5c638c7 | ||
|
|
a51bfd196c | ||
|
|
81f632168b | ||
|
|
6ec7808b25 | ||
|
|
f3770bf545 | ||
|
|
2a873e8bfb | ||
|
|
6968ebed3f | ||
|
|
88c7daf024 | ||
|
|
e72bda24e3 | ||
|
|
b3e514355b | ||
|
|
c530745d8e | ||
|
|
c30629eac4 | ||
|
|
10e641506e | ||
|
|
f1df70aeec | ||
|
|
0d35e58106 | ||
|
|
ae1168ea60 | ||
|
|
a91c578829 | ||
|
|
7ac50de818 | ||
|
|
a61b6c9397 | ||
|
|
8ccb633925 | ||
|
|
96a747518e | ||
|
|
31d0a03d3f | ||
|
|
21752a8b28 | ||
|
|
ef371173c9 | ||
|
|
d460bcab77 | ||
|
|
c5d0520299 | ||
|
|
bf40504ddf | ||
|
|
e0ab7a89cc | ||
|
|
24fd7e89d3 | ||
|
|
287b1a5b10 | ||
|
|
81a2268e1d | ||
|
|
7ddd7d976e | ||
|
|
d43d770024 | ||
|
|
876b214a97 | ||
|
|
57eea26c1a | ||
|
|
a5019da906 | ||
|
|
0b3dbe6ef5 | ||
|
|
c4db4fa664 | ||
|
|
99cef245d0 | ||
|
|
97a2b939cf | ||
|
|
3ebb628a56 | ||
|
|
0c64d703d8 | ||
|
|
852c9a9a3e | ||
|
|
87ac2c18a3 | ||
|
|
3aa8fb19c7 | ||
|
|
ab03f3f734 | ||
|
|
9fb03893b2 | ||
|
|
e6b087319c | ||
|
|
aa567e190e | ||
|
|
6907f4159e | ||
|
|
dc2c63c856 | ||
|
|
dde90817d7 | ||
|
|
559ab4176d | ||
|
|
5f234cc94e | ||
|
|
3936c0d377 | ||
|
|
9fae7c1866 | ||
|
|
814b717aaf | ||
|
|
314e632e47 | ||
|
|
e1fbb78c8a | ||
|
|
f85e312c1a | ||
|
|
f4903fc1bc | ||
|
|
248a07e311 | ||
|
|
8f0bdf698a | ||
|
|
218e1c6f8c | ||
|
|
14bedffe0e | ||
|
|
b772f7c305 | ||
|
|
c8be69796f | ||
|
|
41bf3bfdbb | ||
|
|
7a8dfc3012 | ||
|
|
04706d12c8 | ||
|
|
34d57cda35 | ||
|
|
6c3eaca546 | ||
|
|
05648ce05a | ||
|
|
b59f541a10 | ||
|
|
966f4e0693 | ||
|
|
c3809fbc27 | ||
|
|
886c36a308 | ||
|
|
0630d0e0f1 | ||
|
|
2dac035df0 | ||
|
|
b7da877963 | ||
|
|
34a9a90ab3 | ||
|
|
a5e27bfd47 | ||
|
|
60607354dd | ||
|
|
2c45413a6b | ||
|
|
1828ad9f3b | ||
|
|
a1aa3661d5 | ||
|
|
b12d19c9ea | ||
|
|
ac05f9013a | ||
|
|
601e20fe99 | ||
|
|
9e47e018cf | ||
|
|
a97f5a2baa | ||
|
|
14c107ab71 | ||
|
|
3bb678258f | ||
|
|
cc20e2d339 | ||
|
|
f5e52163b4 | ||
|
|
d3b2c99c60 | ||
|
|
fd0783afee | ||
|
|
319bf4ea2c | ||
|
|
d1306b174c | ||
|
|
aa1e797cf7 | ||
|
|
8ba9d8609b | ||
|
|
7964e56c77 | ||
|
|
6d54f6a8a8 | ||
|
|
498fe87e49 | ||
|
|
9fe3d8bbf1 | ||
|
|
4202534e1f | ||
|
|
c5c76f4009 | ||
|
|
3124c00152 | ||
|
|
bb9427367d | ||
|
|
36c0409e5a | ||
|
|
f1640ff21b | ||
|
|
c949131976 | ||
|
|
fa67089c77 | ||
|
|
a17d9015c1 | ||
|
|
892dee2eb0 | ||
|
|
c980cf68b1 | ||
|
|
b84e29a3f0 | ||
|
|
12ade3a559 | ||
|
|
2faa08c1b6 | ||
|
|
11b8fce668 | ||
|
|
1626b6ec03 | ||
|
|
1cbf2ad892 | ||
|
|
c90b134ded | ||
|
|
72567d3706 | ||
|
|
3919edcc3e | ||
|
|
11c40fa158 | ||
|
|
b044244dc6 | ||
|
|
1ea33829b3 | ||
|
|
79af0241e8 | ||
|
|
c6ee1184ff | ||
|
|
2c277cc311 | ||
|
|
d3dd0467d9 | ||
|
|
a0843d9523 | ||
|
|
475f4b63da | ||
|
|
044a8a1984 | ||
|
|
e88822fb3d | ||
|
|
14deee0df7 | ||
|
|
8f77efae6e | ||
|
|
c93a79887f | ||
|
|
490feb915f | ||
|
|
4825f402fc | ||
|
|
cce3b7b901 | ||
|
|
5816af57bc | ||
|
|
bdcefcb5be | ||
|
|
5ecfb694c5 | ||
|
|
e851fb5bc8 | ||
|
|
8654b9d054 | ||
|
|
93419395c3 | ||
|
|
4936316ef3 | ||
|
|
fef0b7ede9 | ||
|
|
2423adae4c | ||
|
|
b8acba968e | ||
|
|
f660f213f6 | ||
|
|
424fdaaf48 | ||
|
|
5310003659 | ||
|
|
e38b8531da | ||
|
|
a5daa93bf1 | ||
|
|
da8a833485 | ||
|
|
16b955b443 | ||
|
|
4140ba7d7f | ||
|
|
23ed2dcaea | ||
|
|
ac9344cbda | ||
|
|
ce5232841a | ||
|
|
f35f247cb4 | ||
|
|
923d3791cd | ||
|
|
cdea827464 | ||
|
|
58c36b3c92 | ||
|
|
49d80c847e | ||
|
|
fff40b966d | ||
|
|
6f42dfdef9 | ||
|
|
f9dc27a063 | ||
|
|
fd77975c6e | ||
|
|
460a7db190 | ||
|
|
9c4b081f6d | ||
|
|
31a305ffc2 | ||
|
|
17f036522e | ||
|
|
1a3b8fae21 | ||
|
|
172afd0574 | ||
|
|
7666e96542 | ||
|
|
1276bd4b18 | ||
|
|
7c048de845 | ||
|
|
163abc377e | ||
|
|
89edfaa7c7 | ||
|
|
159dc804a2 | ||
|
|
d0dffe7edd | ||
|
|
2d459dd953 | ||
|
|
aede7bf7ec | ||
|
|
9fcdc34b5a | ||
|
|
9ba257dec5 | ||
|
|
87cf7386c6 | ||
|
|
b79b279a17 | ||
|
|
1d96c9d349 | ||
|
|
e5f01e82a2 | ||
|
|
25a2752907 | ||
|
|
c195cfaa19 | ||
|
|
427f030110 | ||
|
|
f0d8d6b89d | ||
|
|
192943cb3e | ||
|
|
31d7d6e76e | ||
|
|
b6f91fe870 | ||
|
|
88ad994a8c | ||
|
|
aa8ff6556b | ||
|
|
0f716a0a16 | ||
|
|
3530a0e9df | ||
|
|
a990ce3dc9 | ||
|
|
3ed915f9d5 | ||
|
|
de2dc3dabb | ||
|
|
3059231363 | ||
|
|
154839594d | ||
|
|
c7635db7e8 | ||
|
|
41e847b944 | ||
|
|
125cd54b66 | ||
|
|
56f2be5817 | ||
|
|
e93934fdf8 | ||
|
|
1ad0dcc0ae | ||
|
|
cee31027e6 | ||
|
|
38c1aa5b4b | ||
|
|
bebb663768 | ||
|
|
f288984833 | ||
|
|
9e68539431 | ||
|
|
a903d57103 | ||
|
|
8c9cd7c202 | ||
|
|
8e14eb81a1 | ||
|
|
4b6e3e5424 | ||
|
|
61f7878acc | ||
|
|
307374ca2b | ||
|
|
975309598a | ||
|
|
697ccabf53 | ||
|
|
775b4109a9 | ||
|
|
977d295680 | ||
|
|
21db702ee7 | ||
|
|
cef5f4963f | ||
|
|
1cd3dc1ac8 | ||
|
|
ef722ec0d0 | ||
|
|
c40cdb281f | ||
|
|
7c37c3f126 | ||
|
|
f082500fc0 | ||
|
|
b6191ab4b0 | ||
|
|
91933a738b | ||
|
|
d77daf41d0 | ||
|
|
489ce3dece | ||
|
|
154207f60f | ||
|
|
84d8ad9144 | ||
|
|
6b7b6480c0 | ||
|
|
3bf37f8838 | ||
|
|
5bb4b5d9a5 | ||
|
|
25be7fd254 | ||
|
|
49542b0851 | ||
|
|
09fa488cff | ||
|
|
c201768ffa | ||
|
|
c91a0c601f | ||
|
|
ccb718b84d | ||
|
|
5b4d490e94 | ||
|
|
1982cbc615 | ||
|
|
b356c65a73 | ||
|
|
d7b5954d42 | ||
|
|
fe1c8b77c9 | ||
|
|
8a103a72cc | ||
|
|
5927258a90 | ||
|
|
a300bc0a11 | ||
|
|
7e9a87f08b | ||
|
|
2c8285651f | ||
|
|
df17dccad7 | ||
|
|
fb732b9398 | ||
|
|
2a23e60cdb | ||
|
|
5a64454906 | ||
|
|
d706224e56 | ||
|
|
f993d0571d | ||
|
|
7dba116937 | ||
|
|
0f67d73b30 | ||
|
|
bedfd6e402 | ||
|
|
d4519ffee6 | ||
|
|
5171e33764 | ||
|
|
e00101e0c0 | ||
|
|
9e31a19f34 | ||
|
|
7ce53b0c23 | ||
|
|
62a4efaa53 | ||
|
|
6801529ca5 | ||
|
|
f814808f20 | ||
|
|
9884a13c6e | ||
|
|
57494b1f81 | ||
|
|
3a0c551668 | ||
|
|
9d5144ddea | ||
|
|
eacfa331e3 | ||
|
|
43efa66c20 | ||
|
|
9f04dc7ed0 | ||
|
|
7de922264a | ||
|
|
7e1e92ae2c | ||
|
|
2ed7e79478 | ||
|
|
0caaa095a2 | ||
|
|
0806d2ac38 | ||
|
|
8b1bce6963 | ||
|
|
fd7c73c354 | ||
|
|
4cca08af79 | ||
|
|
59e21d05ef | ||
|
|
ff41a6e83b | ||
|
|
86bde197ec | ||
|
|
8c61cacb57 | ||
|
|
ef6cbb1090 | ||
|
|
2adc2e3562 | ||
|
|
ce2629a9f4 | ||
|
|
a7af5980a1 | ||
|
|
8a2fc188ae | ||
|
|
f27454a73d | ||
|
|
827c260442 | ||
|
|
a4cd13282a | ||
|
|
100784b51b | ||
|
|
b2963069fc | ||
|
|
ca1b4b03b1 | ||
|
|
4e3fb7e0bd | ||
|
|
0806b3b562 | ||
|
|
fc47c969f1 | ||
|
|
3178aa890d | ||
|
|
c6783e573c | ||
|
|
57930991ec | ||
|
|
f96bf5ba5f | ||
|
|
7a90a5cbbf | ||
|
|
dac491c788 | ||
|
|
d06b1d6304 | ||
|
|
507b8fa2d6 | ||
|
|
55c58cf5d9 | ||
|
|
9812ddc4ce | ||
|
|
61d2d5ce30 | ||
|
|
d4cb398ac1 | ||
|
|
885ee83ede | ||
|
|
edf9f0a9d0 | ||
|
|
6a7c4bf67d |
No files matched your search
+18
-8
@@ -1,18 +1,28 @@
|
||||
# everything
|
||||
/*
|
||||
|
||||
.gradle
|
||||
# IntelliJ
|
||||
/build
|
||||
/run
|
||||
/eclipse
|
||||
/out
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
# minecraft
|
||||
/config
|
||||
/logs
|
||||
/saves
|
||||
/options.txt
|
||||
/usernamecache.json
|
||||
classes/
|
||||
|
||||
changelog.html
|
||||
|
||||
# folders
|
||||
!/gradle/wrapper
|
||||
!/src
|
||||
|
||||
# files
|
||||
!/.gitignore
|
||||
!/LICENSE.txt
|
||||
!/license-header.txt
|
||||
!/README.md
|
||||
!/gradle.properties
|
||||
!/build.gradle
|
||||
!/gradlew
|
||||
!/gradlew.bat
|
||||
@@ -1,13 +1,43 @@
|
||||
## Binnie mods
|
||||
[Binnie mods](https://minecraft.curseforge.com/projects/binnies-mods/files)
|
||||
====================================
|
||||
|
||||
This is an official fork of mod.
|
||||
All builds can be found on [Jenkins](https://ci.bymarcin.com/job/Binnie-Mods-MC1.7.10/)
|
||||
### What is it?
|
||||
Binnie’s Mods is a suite of mods designed to expand the [Forestry](https://github.com/ForestryMC/ForestryMC) mod.
|
||||
It both extends the bee and tree breeding aspect by adding many new species with varied products,
|
||||
along with new features such as fully breedable flowers and genetic manipulation.
|
||||
|
||||
### Warning
|
||||
### Homepage
|
||||
|
||||
Removed unused (unfinished) items and blocks: Honey Crystal, Alcohol, etc.
|
||||
[Wiki](https://binnie.mods.wiki/wiki/Main_Page)
|
||||
|
||||
#### Build
|
||||
[Latest Builds for 1.11 / 1.11.2](http://jenkins.ic2.player.to/job/Binnie's%201.11.2/)
|
||||
|
||||
### Mods
|
||||
|
||||
[](https://binnie.mods.wiki/wiki/Extra_Bees)
|
||||
|
||||
Extra Bees expands upon the bee breeding of Forestry by adding 107 new bee species to forestry. These bees cover a large spectrum of different effects and products, giving you the ability to produce everything from dyes to rare metal dusts purely from bees. It also adds the Apiarist Database, a tool to keep track of discovered species, mutations and traits. There are also new alveary components which help improve and streamline bee production.
|
||||
|
||||
|
||||
[](https://binnie.mods.wiki/wiki/Extra_Trees)
|
||||
|
||||
Extra Trees both increases the number of tree species and adds many new aesthetic uses. There are 96 new tree species, such as Banana, Brazil nut and Douglas-fir. This comes with many new fruits as well as 35 new wooden planks. Extra Trees allows these, as well as Forestry and vanilla planks, to be combined to give doors, gates and various designs of fences. The woodworker allows planks to be combined to give patterned tiles, allowing you to build beautiful wooden floors, and the same can be done with stained glass. A group of machines such as the brewery and distillery allow you to use the fruits you grow to make a variety of wines, ciders and spirits.
|
||||
|
||||
|
||||
[](https://binnie.mods.wiki/wiki/Botany)
|
||||
|
||||
Botany adds an entirely new breeding system to Forestry: flowers. There are 46 different species that can be bred, including both vanilla flowers and new ones such as Fuschia and Lilies. The colour of the flowers can be transferred and selectively bred, meaning that each flower can be one of a possible 80 different colours. These new flowers can be bred manually in small gardens using a trowel and fertiliser, with careful care taken to maintain the desired pH or moisture, or grown on the large scale in Forestry farms.
|
||||
|
||||
[](https://binnie.mods.wiki/wiki/Genetics)
|
||||
|
||||
Genetics is for those who want to eschew conventional breeding, and want to enter the realm of genetic manipulation. Here, genes can be isolated, sequenced and then inoculated back into different species, making it easier to obtain the perfect genome. Bees, trees, butterflies and flowers can all be manipulated in this way. They can also be acclimatised to different environments to build tolerance to hostile climates.
|
||||
|
||||
[](https://binnie.mods.wiki/wiki/Binnie_Core)
|
||||
|
||||
Binnie Core is a mod which contains a lot of the core functionality such as networking and GUI's for the other mods. The only in game features it currently contains are the Compartments
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
The master branch will always contain the latest released version with possibly some bug fixes for that version that will eventually be released.
|
||||
New versions will be created in branched named like {mc_version}-{mod_version}
|
||||
|
||||
+97
-31
@@ -1,68 +1,134 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.47"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "2.0.17"
|
||||
if (System.getenv("BUILD_NUMBER") != null) {
|
||||
version = version + "-" + System.getenv("BUILD_NUMBER")
|
||||
plugins {
|
||||
id "com.matthewprenger.cursegradle" version "1.0.9"
|
||||
}
|
||||
group = "binnie" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "binnie-mods-1.7.10"
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
// uncomment this hack if you use old IDEA
|
||||
/*sourceSets {
|
||||
main {
|
||||
output.resourcesDir = output.classesDir
|
||||
}
|
||||
}*/
|
||||
version = version_major + '.' + version_minor + '.' + version_patch
|
||||
if (System.getenv("BUILD_NUMBER") != null) {
|
||||
version = version + "." + System.getenv("BUILD_NUMBER")
|
||||
}
|
||||
group = "binnie" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "binnie-mods-" + mcversion
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.4.1614-1.7.10"
|
||||
runDir = "eclipse"
|
||||
version = mcversion + "-" + forgeversion
|
||||
mappings = mcp_mappings
|
||||
runDir = "run"
|
||||
|
||||
replace '@VERSION@', project.version
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "jei"
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
name = "ic2, forestry"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
maven {
|
||||
name "Jared"
|
||||
url "http://maven.blamejared.com/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile("net.sengir.forestry:forestry_${mcversion}:${forestry_version}") {
|
||||
transitive = false
|
||||
}
|
||||
deobfProvided "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
runtime "jei-bees:jeibees:${jeibees_version}:mc${mcversion}"
|
||||
deobfProvided "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
runtime "net.industrial-craft:industrialcraft-2:${ic2_version}"
|
||||
deobfProvided "CraftTweaker2:CraftTweaker2-API:${minetweaker_version}"
|
||||
}
|
||||
|
||||
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'
|
||||
expand 'version': project.version,
|
||||
'mcversion': project.minecraft.version,
|
||||
'modid': "BinnieMods"
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
|
||||
// prevent java 8's strict doclint for javadocs from failing builds
|
||||
allprojects {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
repositories {
|
||||
if (project.hasProperty('mavenDir')) {
|
||||
mavenDeployer {
|
||||
repository(url: "file://" + mavenDir)
|
||||
}
|
||||
} else {
|
||||
println 'Archives upload disabled, mavenDir in gradle.properties is missing.'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
|
||||
filePath = "changelog.html"
|
||||
untaggedName = "Current release ${project.version}"
|
||||
fromCommit = "dbc5c1a564c39e4a9c042411d1bdbe450985ce2c"
|
||||
toRef = "HEAD"
|
||||
templateContent = file('changelog.mustache').getText('UTF-8');
|
||||
templateContent = file('changelog.mustache').getText('UTF-8')
|
||||
}
|
||||
|
||||
curseforge {
|
||||
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
|
||||
project {
|
||||
id = curse_project_id
|
||||
changelog = file('changelog.html')
|
||||
changelogType = 'html'
|
||||
releaseType = 'alpha'
|
||||
relations {
|
||||
requiredLibrary 'forestry'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.curseforge223525.dependsOn.add(makeChangelog)
|
||||
}
|
||||
+9
-7
@@ -1,8 +1,10 @@
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
Alpha version. Do not create a world you care about with this version, it may break things severely.<br/>
|
||||
Please help the project by trying it out and <a href="https://github.com/ForestryMC/Binnie/issues">reporting issues here.</a><br/>
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
{{/tags}}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
|
||||
mcversion=1.12
|
||||
forgeversion=14.21.1.2443
|
||||
mcp_mappings=snapshot_20170806
|
||||
curse_project_id=223525
|
||||
|
||||
forestry_version=5.5.0.154
|
||||
ic2_version=2.8.14-ex112
|
||||
|
||||
version_major=2
|
||||
version_minor=2
|
||||
version_patch=0
|
||||
|
||||
jei_version=4.7.4.82
|
||||
jeibees_version=0.9.0.2
|
||||
minetweaker_version=4.0.3.239
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Wed Jul 02 15:54:47 CDT 2014
|
||||
#Thu Jul 13 23:08:17 PDT 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-all.zip
|
||||
@@ -6,12 +6,30 @@
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
# 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
|
||||
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=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -30,6 +48,7 @@ die ( ) {
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
@@ -40,31 +59,11 @@ case "`uname`" in
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# 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
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -90,7 +89,7 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
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
|
||||
@@ -114,6 +113,7 @@ fi
|
||||
if $cygwin ; 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`
|
||||
|
||||
+4
-4
@@ -8,14 +8,14 @@
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@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=
|
||||
|
||||
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=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -46,7 +46,7 @@ echo location of your Java installation.
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,22 +1,20 @@
|
||||
package binnie;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
||||
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 final List<ManagerBase> MANAGERS = new ArrayList<>();
|
||||
public static final ManagerGenetics GENETICS = new ManagerGenetics();
|
||||
public static final ManagerConfig CONFIGURATION = new ManagerConfig();
|
||||
public static final ManagerLiquid LIQUID = new ManagerLiquid();
|
||||
public static final ManagerMachine MACHINE = new ManagerMachine();
|
||||
public static final ManagerResource RESOURCE = new ManagerResource();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package binnie;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
public static final String CORE_MOD_ID = "binniecore";
|
||||
public static final String BOTANY_MOD_ID = "botany";
|
||||
public static final String EXTRA_TREES_MOD_ID = "extratrees";
|
||||
public static final String GENETICS_MOD_ID = "genetics";
|
||||
|
||||
public static final String LIQUID_JUICE = "juice";
|
||||
public static final String LIQUID_WATER = "water";
|
||||
public static final String LIQUID_SEED_OIL = "seedoil";
|
||||
public static final String LIQUID_CREOSOTE = "Creosote Oil";
|
||||
public static final String LIQUID_BIO_ETHANOL = "bioethanol";
|
||||
public static final String LIQUID_FOR_HONEY = "for.honey";
|
||||
}
|
||||
@@ -1,122 +1,115 @@
|
||||
package binnie.botany;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.gardening.IBlockSoil;
|
||||
import binnie.botany.ceramic.BlockCeramic;
|
||||
import binnie.botany.ceramic.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.BlockCeramicPatterned;
|
||||
import binnie.botany.ceramic.BlockStained;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.core.BotanyGUI;
|
||||
import binnie.botany.core.ModuleCore;
|
||||
import binnie.botany.flower.BlockFlower;
|
||||
import binnie.botany.flower.ItemFlower;
|
||||
import binnie.botany.flower.ItemInsulatedTube;
|
||||
import binnie.botany.flower.ItemBotany;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.botany.gardening.BlockPlant;
|
||||
import binnie.botany.gardening.BlockSoil;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.botany.gardening.ItemSoilMeter;
|
||||
import binnie.botany.gardening.ItemTrowel;
|
||||
import binnie.botany.gardening.ModuleGardening;
|
||||
import binnie.botany.genetics.ItemDictionary;
|
||||
import binnie.botany.genetics.ModuleGenetics;
|
||||
import binnie.botany.items.ItemClay;
|
||||
import binnie.botany.items.ItemPigment;
|
||||
import binnie.botany.network.PacketID;
|
||||
import binnie.botany.proxy.Proxy;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.item.ItemMisc;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.network.IPacketID;
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
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",
|
||||
useMetadata = true,
|
||||
dependencies = "after:BinnieCore"
|
||||
modid = Constants.BOTANY_MOD_ID,
|
||||
name = "Binnie's Botany",
|
||||
dependencies = "required-after:" + Constants.CORE_MOD_ID
|
||||
)
|
||||
public class Botany extends AbstractMod {
|
||||
@Mod.Instance("Botany")
|
||||
public static final float AGE_CHANCE = 0.2f;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Mod.Instance(Constants.BOTANY_MOD_ID)
|
||||
public static Botany instance;
|
||||
|
||||
@SidedProxy(
|
||||
clientSide = "binnie.botany.proxy.ProxyClient",
|
||||
serverSide = "binnie.botany.proxy.ProxyServer"
|
||||
)
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
|
||||
public static Proxy proxy;
|
||||
|
||||
/* MODULE GENETIC */
|
||||
public static BlockFlower flower;
|
||||
public static Item seed;
|
||||
public static Item pollen;
|
||||
public static ItemBotany flowerItem;
|
||||
public static ItemBotany seed;
|
||||
public static ItemBotany 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;
|
||||
@Nullable
|
||||
public static Item botanistBackpack;
|
||||
|
||||
public Botany() {
|
||||
Botany.instance = this;
|
||||
}
|
||||
@Nullable
|
||||
private static ModuleGardening gardening;
|
||||
@Nullable
|
||||
private static ModuleGenetics genetics;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
addModule(new ModuleCore());
|
||||
addModule(new ModuleGenetics());
|
||||
addModule(new ModuleGardening());
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
postInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModules() {
|
||||
addModule(new ModuleCore());
|
||||
addModule(genetics = new ModuleGenetics());
|
||||
addModule(gardening = new ModuleGardening());
|
||||
}
|
||||
|
||||
public static ModuleGardening gardening() {
|
||||
Preconditions.checkState(gardening != null);
|
||||
return gardening;
|
||||
}
|
||||
|
||||
public static ModuleGenetics genetics() {
|
||||
Preconditions.checkState(genetics != null);
|
||||
return genetics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BotanyGUI.values();
|
||||
@@ -144,7 +137,7 @@ public class Botany extends AbstractMod {
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "botany";
|
||||
return Constants.BOTANY_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,185 +145,171 @@ public class Botany extends AbstractMod {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return BinnieCore.isBotanyActive();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShearFlower(PlayerInteractEvent event) {
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
public void onShearFlower(PlayerInteractEvent.RightClickBlock event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player == 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) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
flower.onShear();
|
||||
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
|
||||
}
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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--;
|
||||
}
|
||||
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (heldItem.getItem() == Items.SHEARS) {
|
||||
flower.onShear();
|
||||
heldItem.damageItem(1, player);
|
||||
} else if (heldItem.getItem() == Botany.pollen) {
|
||||
IFlower pollen = BotanyCore.getFlowerRoot().getMember(heldItem);
|
||||
if (pollen != null && flower.canMateWith(pollen)) {
|
||||
flower.mateWith(pollen);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onFertiliseSoil(PlayerInteractEvent event) {
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
|
||||
public void onFertiliseSoil(PlayerInteractEvent.RightClickBlock event) {
|
||||
World world = event.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
|
||||
BlockPos pos = event.getPos();
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (block == null || !Gardening.isSoil(block)) {
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
Block block = world.getBlockState(event.getPos()).getBlock();
|
||||
if (!gardening.isSoil(block)) {
|
||||
pos = pos.down();
|
||||
block = world.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
if (!gardening.isSoil(block)) {
|
||||
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--;
|
||||
int fertiliserStrength = gardening.getFertiliserStrength(heldItem);
|
||||
if (gardening.isNutrientFertiliser(heldItem) && soil.getType(world, pos) != EnumSoilType.FLOWERBED) {
|
||||
EnumSoilType type = soil.getType(world, pos);
|
||||
int next = Math.min(type.ordinal() + fertiliserStrength, 2);
|
||||
if (soil.fertilise(world, pos, EnumSoilType.values()[next]) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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--;
|
||||
if (gardening.isAcidFertiliser(heldItem) && soil.getPH(world, pos) != EnumAcidity.ACID) {
|
||||
EnumAcidity pH = soil.getPH(world, pos);
|
||||
int next = Math.max(pH.ordinal() - fertiliserStrength, 0);
|
||||
if (soil.setPH(world, pos, EnumAcidity.values()[next]) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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--;
|
||||
if (gardening.isAlkalineFertiliser(heldItem) && soil.getPH(world, pos) != EnumAcidity.ALKALINE) {
|
||||
EnumAcidity pH = soil.getPH(world, pos);
|
||||
int next = Math.min(pH.ordinal() + fertiliserStrength, 2);
|
||||
if (soil.setPH(world, pos, EnumAcidity.values()[next]) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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--;
|
||||
if (gardening.isWeedkiller(heldItem) && gardening.addWeedKiller(world, pos) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
@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)) {
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos.down()).getBlock();
|
||||
if (!BotanyCore.getGardening().isSoil(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
|
||||
EntityPlayer player = event.getPlayer();
|
||||
ItemStack heldItem = player.getHeldItem(event.getHand());
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(heldItem);
|
||||
if (flower != null) {
|
||||
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
|
||||
flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) {
|
||||
BlockPos pos = event.getPos();
|
||||
World world = event.getWorld();
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (!BinnieCore.getBinnieProxy().isSimulating(event.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
World world = event.world;
|
||||
int x = event.x;
|
||||
int y = event.y;
|
||||
int z = event.z;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) {
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
|
||||
py = 1;
|
||||
}
|
||||
|
||||
if (py < 0) {
|
||||
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--;
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(heldItem);
|
||||
if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBonemeal(BonemealEvent event) {
|
||||
Block block = event.world.getBlock(event.x, event.y, event.z);
|
||||
if (Gardening.isSoil(block)) {
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = event.getBlock().getBlock();
|
||||
if (BotanyCore.getGardening().isSoil(block)) {
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
|
||||
if (soil.fertilise(event.getWorld(), pos, EnumSoilType.LOAM)) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
TileEntity tile = event.getWorld().getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return BinnieCore.isBotanyActive();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
super(Botany.instance);
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
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 net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class CreativeTabBotany extends CreativeTabs {
|
||||
public static CreativeTabs instance = new CreativeTabBotany();
|
||||
|
||||
@@ -17,10 +18,11 @@ public class CreativeTabBotany extends CreativeTabs {
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Blocks.red_flower, 1, 5);
|
||||
return new ItemStack(Blocks.RED_FLOWER, 1, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTranslatedTabLabel() {
|
||||
return getTabLabel();
|
||||
}
|
||||
@@ -33,7 +35,7 @@ public class CreativeTabBotany extends CreativeTabs {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getTabIconItem() {
|
||||
return Item.getItemFromBlock(Blocks.yellow_flower);
|
||||
public ItemStack getTabIconItem() {
|
||||
return new ItemStack(Blocks.YELLOW_FLOWER);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,34 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumAcidity {
|
||||
ACID,
|
||||
NEUTRAL,
|
||||
ALKALINE;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public String getID() {
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumAcidity implements IStringSerializable {
|
||||
ACID(TextFormatting.RED),
|
||||
NEUTRAL(null),
|
||||
ALKALINE(TextFormatting.AQUA);
|
||||
|
||||
@Nullable
|
||||
TextFormatting color;
|
||||
|
||||
EnumAcidity(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName(boolean withColor) {
|
||||
String localisedName = I18N.localise("botany.ph." + getName());
|
||||
if (withColor && color != null) {
|
||||
localisedName += color;
|
||||
}
|
||||
return localisedName;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleArea;
|
||||
@@ -36,7 +38,7 @@ public enum EnumFlowerChromosome implements IChromosomeType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase();
|
||||
return toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,31 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumFlowerStage {
|
||||
import forestry.api.genetics.ISpeciesType;
|
||||
|
||||
public enum EnumFlowerStage implements ISpeciesType {
|
||||
FLOWER("Flower"),
|
||||
SEED("Seed"),
|
||||
POLLEN("Pollen"),
|
||||
NONE("NONE");
|
||||
POLLEN("Pollen");
|
||||
|
||||
protected String name;
|
||||
public static final EnumFlowerStage[] VALUES = values();
|
||||
String name;
|
||||
|
||||
EnumFlowerStage(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static EnumFlowerStage getStage(IFlower flower) {
|
||||
return getStage(flower.getAge());
|
||||
}
|
||||
|
||||
public static EnumFlowerStage getStage(int age) {
|
||||
return age == 0
|
||||
? EnumFlowerStage.SEED
|
||||
: EnumFlowerStage.FLOWER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,34 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumMoisture {
|
||||
DRY,
|
||||
NORMAL,
|
||||
DAMP;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public String getID() {
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumMoisture implements IStringSerializable {
|
||||
DRY(TextFormatting.YELLOW),
|
||||
NORMAL(null),
|
||||
DAMP(TextFormatting.DARK_BLUE);
|
||||
|
||||
@Nullable
|
||||
final TextFormatting color;
|
||||
|
||||
EnumMoisture(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName(boolean withColor) {
|
||||
String localisedName = I18N.localise("botany.moisture." + getName());
|
||||
if (withColor && color != null) {
|
||||
localisedName += color;
|
||||
}
|
||||
return localisedName;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,29 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumSoilType {
|
||||
SOIL,
|
||||
LOAM,
|
||||
FLOWERBED;
|
||||
import java.util.Locale;
|
||||
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumSoilType implements IStringSerializable {
|
||||
SOIL(TextFormatting.DARK_GRAY),
|
||||
LOAM(TextFormatting.GOLD),
|
||||
FLOWERBED(TextFormatting.LIGHT_PURPLE);
|
||||
|
||||
private final TextFormatting color;
|
||||
|
||||
EnumSoilType(TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getTranslated() {
|
||||
return color + I18N.localise("botany.soil." + getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public class FlowerManager {
|
||||
/**
|
||||
* Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers")
|
||||
*/
|
||||
public static IFlowerRoot flowerRoot;
|
||||
|
||||
/**
|
||||
* Used to create new flowers.
|
||||
*/
|
||||
public static IFlowerFactory flowerFactory;
|
||||
|
||||
/**
|
||||
* Used to manager soil.
|
||||
*/
|
||||
public static IGardeningManager gardening;
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
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 effect, World world, int x, int y, int z);
|
||||
}
|
||||
@@ -1,11 +1,28 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IAlleleProperty;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public interface IAlleleFlowerSpecies extends IAlleleSpecies {
|
||||
public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleFlowerSpecies> {
|
||||
IFlowerType getType();
|
||||
|
||||
EnumAcidity getPH();
|
||||
|
||||
EnumMoisture getMoisture();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
int getFlowerColor(EnumFlowerStage type, int renderPass);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpeciesBuilder;
|
||||
|
||||
public interface IAlleleFlowerSpeciesBuilder extends IAlleleSpeciesBuilder {
|
||||
@Override
|
||||
IAlleleFlowerSpecies build();
|
||||
|
||||
IAlleleFlowerSpeciesBuilder setPH(EnumAcidity acidity);
|
||||
|
||||
IAlleleFlowerSpeciesBuilder setMoisture(EnumMoisture moisture);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IBlockSoil {
|
||||
EnumAcidity getPH(World world, BlockPos pos);
|
||||
|
||||
EnumMoisture getMoisture(World world, BlockPos pos);
|
||||
|
||||
EnumSoilType getType(World world, BlockPos pos);
|
||||
|
||||
boolean fertilise(World world, BlockPos pos, EnumSoilType soilType);
|
||||
|
||||
boolean degrade(World world, BlockPos pos, EnumSoilType soilType);
|
||||
|
||||
boolean setPH(World world, BlockPos pos, EnumAcidity acidity);
|
||||
|
||||
boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture);
|
||||
|
||||
boolean resistsWeeds(World world, BlockPos pos);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public interface IColorMix {
|
||||
IFlowerColor getColorFirst();
|
||||
|
||||
IFlowerColor getColorSecond();
|
||||
|
||||
boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond);
|
||||
|
||||
int getChance();
|
||||
|
||||
IFlowerColor getResult();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public interface IColourMix {
|
||||
IFlowerColor getColor1();
|
||||
|
||||
IFlowerColor getColor2();
|
||||
|
||||
boolean isMutation(IFlowerColor color1, IFlowerColor color2);
|
||||
|
||||
int getChance();
|
||||
|
||||
IFlowerColor getResult();
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public interface IFlower extends IIndividual {
|
||||
@Override
|
||||
IFlowerGenome getGenome();
|
||||
|
||||
@Nullable
|
||||
IFlowerGenome getMate();
|
||||
|
||||
void mate(IFlower other);
|
||||
void mate(IFlower flower);
|
||||
|
||||
int getAge();
|
||||
|
||||
@@ -17,17 +22,17 @@ public interface IFlower extends IIndividual {
|
||||
|
||||
void age();
|
||||
|
||||
IFlower getOffspring(World world);
|
||||
IFlower getOffspring(World world, BlockPos pos);
|
||||
|
||||
int getMaxAge();
|
||||
|
||||
boolean isWilted();
|
||||
|
||||
void setWilted(boolean value);
|
||||
void setWilted(boolean p0);
|
||||
|
||||
boolean hasFlowered();
|
||||
|
||||
void setFlowered(boolean value);
|
||||
void setFlowered(boolean p0);
|
||||
|
||||
void removeMate();
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public interface IFlowerColor {
|
||||
|
||||
int getID();
|
||||
|
||||
String getName();
|
||||
String getColorName();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.genetics.IGeneticDefinition;
|
||||
|
||||
public interface IFlowerDefinition extends IGeneticDefinition {
|
||||
@Override
|
||||
IFlowerGenome getGenome();
|
||||
|
||||
@Override
|
||||
IFlower getIndividual();
|
||||
|
||||
ItemStack getMemberStack(EnumFlowerStage flowerStage);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
public interface IFlowerFactory {
|
||||
IAlleleFlowerSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean isDominant, IClassification branch, String binomial, IFlowerType flowerType);
|
||||
|
||||
IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] result, int chance);
|
||||
}
|
||||
@@ -33,9 +33,9 @@ public interface IFlowerGenome extends IGenome {
|
||||
|
||||
float getSappiness();
|
||||
|
||||
boolean canTolerate(EnumAcidity pH);
|
||||
boolean canTolerate(EnumAcidity acidity);
|
||||
|
||||
boolean canTolerate(EnumMoisture moisture);
|
||||
|
||||
boolean canTolerate(EnumTemperature temp);
|
||||
boolean canTolerate(EnumTemperature temperature);
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
public interface IFlowerMutation extends IMutation {
|
||||
float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
|
||||
@Override
|
||||
IFlowerRoot getRoot();
|
||||
|
||||
float getChance(World world, BlockPos pos, IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IFlowerGenome genome0, IFlowerGenome genome1);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IMutationBuilder;
|
||||
|
||||
public interface IFlowerMutationBuilder extends IMutationBuilder {
|
||||
}
|
||||
@@ -1,22 +1,28 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Collection;
|
||||
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);
|
||||
@Nullable
|
||||
IFlower getMember(ItemStack memberStack);
|
||||
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
IFlower templateAsIndividual(IAllele[] templateFirst, IAllele[] templateSecond);
|
||||
|
||||
@Override
|
||||
IFlowerGenome templateAsGenome(IAllele[] template);
|
||||
@@ -25,20 +31,29 @@ public interface IFlowerRoot extends ISpeciesRoot {
|
||||
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
@Override
|
||||
IBotanistTracker getBreedingTracker(World world, GameProfile player);
|
||||
IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile profile);
|
||||
|
||||
@Override
|
||||
Collection<IFlowerMutation> getMutations(boolean shuffle);
|
||||
List<? extends IFlowerMutation> getMutations(boolean shuffle);
|
||||
|
||||
EnumFlowerStage getStageType(ItemStack stack);
|
||||
@Override
|
||||
@Nullable
|
||||
EnumFlowerStage getType(ItemStack itemStack);
|
||||
|
||||
IFlower getFlower(World world, IFlowerGenome genome);
|
||||
IFlower getFlower(IFlowerGenome genome);
|
||||
|
||||
void addConversion(ItemStack stack, IAllele[] template);
|
||||
void addConversion(ItemStack memberStack, IAllele[] template);
|
||||
|
||||
IFlower getConversion(ItemStack stack);
|
||||
@Nullable
|
||||
IFlower getConversion(ItemStack memberStack);
|
||||
|
||||
Collection<IColourMix> getColourMixes(boolean shuffle);
|
||||
Collection<IColorMix> getColorMixes(boolean shuffle);
|
||||
|
||||
void registerColourMix(IColourMix colorMix);
|
||||
void registerColourMix(IColorMix colorMix);
|
||||
|
||||
boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner);
|
||||
|
||||
void tryGrowSection(World world, BlockPos pos);
|
||||
|
||||
void onGrowFromSeed(World world, BlockPos pos);
|
||||
}
|
||||
@@ -1,13 +1,21 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public interface IFlowerType {
|
||||
IIcon getStem(EnumFlowerStage stage, boolean flowered, int section);
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section);
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section);
|
||||
public interface IFlowerType<I extends IFlowerType<I>> extends Comparable<I> {
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered);
|
||||
|
||||
String getName();
|
||||
|
||||
int getID();
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
public interface IGardeningManager {
|
||||
default boolean isSoil(Block block) {
|
||||
return block instanceof IBlockSoil;
|
||||
}
|
||||
|
||||
boolean isSoil(Item item);
|
||||
|
||||
boolean isSoil(ItemStack item);
|
||||
|
||||
EnumMoisture getNaturalMoisture(World world, BlockPos pos);
|
||||
|
||||
EnumAcidity getNaturalPH(World world, BlockPos pos);
|
||||
|
||||
float getBiomeMoisture(World world, BlockPos pos);
|
||||
|
||||
float getBiomePH(World world, BlockPos pos);
|
||||
|
||||
void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity);
|
||||
|
||||
Collection<ItemStack> getAcidFertilisers();
|
||||
|
||||
Collection<ItemStack> getAlkalineFertilisers();
|
||||
|
||||
Collection<ItemStack> getNutrientFertilisers();
|
||||
|
||||
void registerAcidFertiliser(ItemStack stack, int strength);
|
||||
|
||||
void registerAlkalineFertiliser(ItemStack stack, int strength);
|
||||
|
||||
void registerNutrientFertiliser(ItemStack stack, int strength);
|
||||
|
||||
boolean isAcidFertiliser(ItemStack stack);
|
||||
|
||||
boolean isAlkalineFertiliser(ItemStack stack);
|
||||
|
||||
boolean isNutrientFertiliser(ItemStack stack);
|
||||
|
||||
int getFertiliserStrength(ItemStack stack);
|
||||
|
||||
boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos);
|
||||
|
||||
EnumSoilType getSoilType(World world, BlockPos pos);
|
||||
|
||||
default Block getSoilBlock(EnumSoilType type) {
|
||||
return getSoilBlock(type, false);
|
||||
}
|
||||
|
||||
Block getSoilBlock(EnumSoilType type, boolean weedKill);
|
||||
|
||||
boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature);
|
||||
|
||||
boolean isWeedkiller(ItemStack heldItem);
|
||||
|
||||
boolean addWeedKiller(World world, BlockPos pos);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package binnie.botany.api.gardening;
|
||||
|
||||
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);
|
||||
|
||||
EnumSoilType getType(World world, int x, int y, int z);
|
||||
|
||||
boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel);
|
||||
|
||||
boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel);
|
||||
|
||||
boolean setPH(World world, int x, int y, int z, EnumAcidity pH);
|
||||
|
||||
boolean setMoisture(World world, int x, int y, int z, EnumMoisture p4);
|
||||
|
||||
boolean resistsWeeds(World world, int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.botany.api;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,146 +1,118 @@
|
||||
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 javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.util.MovingObjectPosition;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
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 net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCeramic extends Block implements IBlockMetadata {
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.TileUtil;
|
||||
|
||||
public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegister {
|
||||
public BlockCeramic() {
|
||||
super(Material.rock);
|
||||
super(Material.ROCK);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setBlockName("ceramic");
|
||||
setRegistryName("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);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
manager.registerItemModel(item, c.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, @Nullable EntityPlayer player, boolean willHarvest) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
drops = Collections.singletonList(ceramic.getStack());
|
||||
}
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileCeramic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@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);
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
TileCeramic ceramic = TileUtil.getTile(worldIn, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
ceramic.setColor(EnumFlowerColor.VALUES[stack.getItemDamage()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
||||
return TileEntityMetadata.getItemDamage(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(ItemStack itemStack) {
|
||||
return I18N.localise("botany.ceramicBlock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockTooltip(ItemStack stack, List tooltip) {
|
||||
int meta = TileEntityMetadata.getItemDamage(stack);
|
||||
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List itemList) {
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
|
||||
itemList.add(new ItemStack(this, 1, c.getFlowerColorAllele().getID()));
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
return ceramic.getStack();
|
||||
}
|
||||
return super.getIcon(world, x, y, z, side);
|
||||
return super.getPickBlock(state, target, world, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
blockIcon = Botany.proxy.getIcon(register, "ceramic");
|
||||
}
|
||||
|
||||
@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());
|
||||
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
|
||||
if (world != null && pos != null) {
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
return ceramic.getColor().getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@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 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);
|
||||
return EnumFlowerColor.get(0).getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,553 +0,0 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.block.MultipassBlockRenderer;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
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.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipassBlock {
|
||||
public BlockCeramicBrick() {
|
||||
super(Material.rock);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setBlockName("ceramicBrick");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
private static BlockType getType(int meta) {
|
||||
return new BlockType(meta);
|
||||
}
|
||||
|
||||
@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 boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
|
||||
return BlockMetadata.breakBlock(this, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
||||
return TileEntityMetadata.getItemDamage(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(ItemStack itemStack) {
|
||||
int meta = TileEntityMetadata.getItemDamage(itemStack);
|
||||
return getType(meta).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
|
||||
int meta = TileEntityMetadata.getItemDamage(itemStack);
|
||||
getType(meta).addTooltip(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
BlockType type = new BlockType(c, c, TileType.Tile);
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, type.ordinal()));
|
||||
}
|
||||
|
||||
for (TileType type2 : TileType.values()) {
|
||||
if (type2.canDouble()) {
|
||||
itemList.add(new BlockType(EnumFlowerColor.BROWN, EnumFlowerColor.GOLD, type2).getStack(1));
|
||||
}
|
||||
}
|
||||
|
||||
itemList.add(new BlockType(EnumFlowerColor.GOLD, EnumFlowerColor.GOLD, TileType.Split).getStack(1));
|
||||
itemList.add(new BlockType(EnumFlowerColor.BROWN, EnumFlowerColor.BROWN, TileType.Chequered).getStack(1));
|
||||
itemList.add(new BlockType(EnumFlowerColor.GOLD, EnumFlowerColor.BROWN, TileType.LargeBrick).getStack(1));
|
||||
}
|
||||
|
||||
@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 IIcon getIcon(int side, int meta) {
|
||||
return getType(meta).getIcon(MultipassBlockRenderer.getLayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (TileType type : TileType.values()) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
type.icons[i] = Botany.proxy.getIcon(register, "ceramic." + type.id + "." + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 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 ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
return BlockMetadata.getPickBlock(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor(int meta) {
|
||||
return colorMultiplier(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfPasses() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(int meta) {
|
||||
BlockType type = getType(meta);
|
||||
if (MultipassBlockRenderer.getLayer() == 0) {
|
||||
return 0xffffff;
|
||||
}
|
||||
if (MultipassBlockRenderer.getLayer() == 1) {
|
||||
return type.color1.getColor(false);
|
||||
}
|
||||
return type.color2.getColor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BinnieCore.multipassRenderID;
|
||||
}
|
||||
|
||||
public enum TileType {
|
||||
Tile("tile", "ceramicTile"),
|
||||
Brick("brick", "ceramicBricks"),
|
||||
StripeBrick("brickstripe", "strippedCeramicBricks"),
|
||||
LargeBrick("bricklarge", "largeCeramicBricks"),
|
||||
Split("split", "splitCeramicTile"),
|
||||
Chequered("cheque", "chequeredCeramicTile"),
|
||||
Mixed("mixed", "mixedCeramicTile"),
|
||||
VerticalBrick("verticalbrick", "verticalCeramicBricks"),
|
||||
VerticalStripeBrick("verticalbrickstripe", "verticalStripedCeramicBricks"),
|
||||
VerticalLargeBrick("verticalbricklarge", "largeVerticalCeramicBricks");
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected IIcon[] icons;
|
||||
|
||||
TileType(String id, String name) {
|
||||
icons = new IIcon[3];
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static TileType get(int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public boolean canDouble() {
|
||||
return this != TileType.Tile;
|
||||
}
|
||||
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
switch (this) {
|
||||
case Tile:
|
||||
return getTileRecipe(stacks);
|
||||
|
||||
case Split:
|
||||
return getSplitRecipe(stacks);
|
||||
|
||||
case Chequered:
|
||||
return getChequeredRecipe(stacks);
|
||||
|
||||
case Mixed:
|
||||
return getMixedRecipe(stacks);
|
||||
|
||||
case LargeBrick:
|
||||
return getLargeBrickRecipe(stacks);
|
||||
|
||||
case Brick:
|
||||
case StripeBrick:
|
||||
return getBrickRecipe(stacks);
|
||||
|
||||
case VerticalLargeBrick:
|
||||
case VerticalBrick:
|
||||
case VerticalStripeBrick:
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack getTileRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int mortars = 0;
|
||||
int blockColor = -1;
|
||||
for (ItemStack stack : stacks) {
|
||||
if (isMortar(stack)) {
|
||||
mortars++;
|
||||
} else {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else if (blockColor != color) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mortars != 1) {
|
||||
return null;
|
||||
}
|
||||
EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new BlockType(c, c, TileType.Tile).getStack(3);
|
||||
}
|
||||
|
||||
private ItemStack getSplitRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] colors = {-1, -1};
|
||||
int altCounter = 0;
|
||||
for (ItemStack stack : stacks) {
|
||||
int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockType type = new BlockType(stack);
|
||||
if (type.type != TileType.Tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color2 = type.color1.ordinal();
|
||||
if (colors[alt] == -1) {
|
||||
colors[alt] = color2;
|
||||
} else if (colors[alt] != color2) {
|
||||
return null;
|
||||
}
|
||||
altCounter++;
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Split).getStack(4);
|
||||
}
|
||||
|
||||
private ItemStack getChequeredRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockType type2 = new BlockType(stack);
|
||||
if (type2.type != TileType.Split) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color1 = type2.color1.ordinal();
|
||||
int color2 = type2.color2.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color1;
|
||||
colors[1] = color2;
|
||||
} else if (colors[0] != color1 || colors[1] != color2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Chequered).getStack(4);
|
||||
}
|
||||
|
||||
private ItemStack getMixedRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockType type2 = new BlockType(stack);
|
||||
if (type2.isTwoColors()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color3 = type2.color1.ordinal();
|
||||
if (type2.type == TileType.Split) {
|
||||
if (colors[1] != -1) {
|
||||
return null;
|
||||
}
|
||||
colors[1] = color3;
|
||||
} else {
|
||||
if (type2.type != TileType.Chequered) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
} else if (colors[0] != color3) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (colors[0] == -1 || colors[1] == -1) {
|
||||
return null;
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Mixed).getStack(4);
|
||||
}
|
||||
|
||||
private ItemStack getLargeBrickRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
ItemStack stack3 = stacks.get(0);
|
||||
BlockType type3 = new BlockType(stack3);
|
||||
if (type3.type == TileType.VerticalLargeBrick) {
|
||||
type3.type = this;
|
||||
return type3.getStack(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stacks.size() != 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockType type4 = new BlockType(stack4);
|
||||
if (type4.type != TileType.Tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color5 = type4.color1.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color5;
|
||||
} else if (colors[1] == -1) {
|
||||
colors[1] = color5;
|
||||
} else if (colors[1] != color5) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (colors[1] == -1) {
|
||||
colors[1] = colors[0];
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.LargeBrick).getStack(3);
|
||||
}
|
||||
|
||||
private ItemStack getBrickRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
ItemStack stack = stacks.get(0);
|
||||
BlockType type = new BlockType(stack);
|
||||
if (type.type == TileType.VerticalBrick) {
|
||||
type.type = this;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == TileType.StripeBrick) {
|
||||
type.type = this;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] colors = {-1, -1};
|
||||
for (int index2 = 0; index2 < stacks.size(); ++index2) {
|
||||
ItemStack stack = stacks.get(index2);
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockType type = new BlockType(stack);
|
||||
if (type.type != TileType.LargeBrick) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int color5 = type.color1.ordinal();
|
||||
int color6 = type.color2.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (this == TileType.StripeBrick) {
|
||||
alt2 = 0;
|
||||
}
|
||||
|
||||
if (colors[alt2] == -1) {
|
||||
colors[alt2] = color5;
|
||||
colors[1 - alt2] = color6;
|
||||
} else if (colors[alt2] != color5 || colors[1 - alt2] != color6) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), this).getStack(4);
|
||||
}
|
||||
|
||||
private ItemStack getVerticalBrickRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack5 = stacks.get(0);
|
||||
BlockType type = new BlockType(stack5);
|
||||
if (type.type == TileType.LargeBrick) {
|
||||
type.type = TileType.VerticalLargeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == TileType.Brick) {
|
||||
type.type = TileType.VerticalBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == TileType.StripeBrick) {
|
||||
type.type = TileType.VerticalStripeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isMortar(ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc
|
||||
&& stack.getItemDamage() == BotanyItems.Mortar.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockType {
|
||||
protected EnumFlowerColor color1;
|
||||
protected EnumFlowerColor color2;
|
||||
protected TileType type;
|
||||
|
||||
private BlockType(EnumFlowerColor color1, EnumFlowerColor color2, TileType type) {
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return type.canDouble() && color2 != color1;
|
||||
}
|
||||
|
||||
public BlockType(ItemStack stack) {
|
||||
this(TileEntityMetadata.getItemDamage(stack));
|
||||
}
|
||||
|
||||
public ItemStack getStack(int stackSize) {
|
||||
ItemStack stack = TileEntityMetadata.getItemStack(Botany.ceramicBrick, ordinal());
|
||||
stack.stackSize = stackSize;
|
||||
return stack;
|
||||
}
|
||||
|
||||
public BlockType(int id) {
|
||||
color1 = EnumFlowerColor.get(id & 0xFF);
|
||||
color2 = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
type = TileType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return I18N.localise("botany." + type.name);
|
||||
}
|
||||
|
||||
public void addTooltip(List tooltip) {
|
||||
String name = color1.getName();
|
||||
if (type.canDouble() && color2 != color1) {
|
||||
name = I18N.localise("botany.colour.double", name, color2.getName());
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.GRAY + name);
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return color1.ordinal() + color2.ordinal() * 256 + type.ordinal() * 65536;
|
||||
}
|
||||
|
||||
public IIcon getIcon(int layer) {
|
||||
return type.icons[layer];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,32 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.util.I18N;
|
||||
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);
|
||||
super(CeramicDesignSystem.instance, Material.ROCK);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setBlockName("ceramicPattern");
|
||||
setRegistryName("ceramicPattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCreativeStack(IDesign design) {
|
||||
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.WHITE), CeramicColor.get(EnumFlowerColor.BLACK), design);
|
||||
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.White), CeramicColor.get(EnumFlowerColor.Black), design);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(DesignBlock design) {
|
||||
return I18N.localise("botany.ceramicBlock");
|
||||
}
|
||||
|
||||
@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());
|
||||
return I18N.localise("botany.ceramic.block.name", design.getDesign().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.util.MovingObjectPosition;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@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 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 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 TileEntity createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
||||
return TileEntityMetadata.getItemDamage(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(ItemStack itemStack) {
|
||||
return I18N.localise("botany.pigmentedGlass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockTooltip(ItemStack itemStack, List tooltip) {
|
||||
int meta = TileEntityMetadata.getItemDamage(itemStack);
|
||||
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World world, int x, int y, int z, ItemStack stack) {
|
||||
dropBlockAsItem(world, x, y, z, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
@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 IIcon getIcon(int side, int meta) {
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
blockIcon = Botany.proxy.getIcon(register, "stained");
|
||||
}
|
||||
|
||||
@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 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 boolean isWood(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
|
||||
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;
|
||||
|
||||
public class BlockStainedGlass extends Block implements IBlockMetadata, IColoredBlock, IItemModelRegister {
|
||||
public BlockStainedGlass() {
|
||||
super(Material.GLASS);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("stained");
|
||||
setSoundType(SoundType.GLASS);
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
manager.registerItemModel(item, color.getFlowerColorAllele().getID());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
|
||||
Block block = iblockstate.getBlock();
|
||||
return block != this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
|
||||
player.addStat(StatList.getBlockStats(this));
|
||||
player.addExhaustion(0.005F);
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0 && te instanceof TileEntityMetadata) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
TileEntityMetadata tile = (TileEntityMetadata) te;
|
||||
int damage = getDroppedMeta(state, tile.getTileMetadata());
|
||||
ItemStack itemstack = TileEntityMetadata.getItemStack(this, damage);
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
items.add(itemstack);
|
||||
}
|
||||
|
||||
ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
|
||||
for (ItemStack item : items) {
|
||||
spawnAsEntity(worldIn, pos, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
return tileentity != null && tileentity.receiveClientEvent(id, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack stack, World world, BlockPos pos, EnumFacing clickedBlock) {
|
||||
return TileEntityMetadata.getItemDamage(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(IBlockState state, int tileMetadata) {
|
||||
return tileMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(ItemStack itemStack) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getItemDamage(itemStack));
|
||||
return I18N.localise("botany.pigmented.glass.name", color.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, color.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWood(IBlockAccess world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
|
||||
if (worldIn == null || pos == null) {
|
||||
return 0;
|
||||
}
|
||||
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getTileMetadata(worldIn, pos));
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
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;
|
||||
private final static Map<EnumFlowerColor, CeramicColor> map = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
CeramicColor.map = new LinkedHashMap<>();
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
CeramicColor.map.put(c, new CeramicColor(c));
|
||||
}
|
||||
}
|
||||
|
||||
protected EnumFlowerColor color;
|
||||
EnumFlowerColor color;
|
||||
|
||||
CeramicColor(EnumFlowerColor color) {
|
||||
this.color = color;
|
||||
@@ -31,16 +31,21 @@ public class CeramicColor implements IDesignMaterial {
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal());
|
||||
return TileEntityMetadata.getItemStack(Botany.gardening().ceramic, color.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public ItemStack getStack(boolean fireproof) {
|
||||
return getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesignMaterialName() {
|
||||
return color.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return color.getColor(false);
|
||||
public int getColour() {
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,33 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
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;
|
||||
Map<Integer, TextureAtlasSprite> primary;
|
||||
Map<Integer, TextureAtlasSprite> secondary;
|
||||
|
||||
CeramicDesignSystem() {
|
||||
primary = new HashMap<>();
|
||||
@@ -32,12 +37,12 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial() {
|
||||
return CeramicColor.get(EnumFlowerColor.WHITE);
|
||||
return CeramicColor.get(EnumFlowerColor.White);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial2() {
|
||||
return CeramicColor.get(EnumFlowerColor.BLACK);
|
||||
return CeramicColor.get(EnumFlowerColor.Black);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,11 +56,13 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
}
|
||||
|
||||
public String getTexturePath() {
|
||||
return "ceramic";
|
||||
return "blocks/ceramic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getPrimaryIcon(IPattern pattern) {
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPrimarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return primary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
@@ -63,7 +70,9 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getSecondaryIcon(IPattern pattern) {
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSecondarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return secondary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
@@ -71,10 +80,14 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites() {
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
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"));
|
||||
ResourceLocation primaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0");
|
||||
ResourceLocation secondaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1");
|
||||
primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation));
|
||||
secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +97,14 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
|
||||
@Override
|
||||
public ItemStack getAdhesive() {
|
||||
return BotanyItems.Mortar.get(1);
|
||||
return BotanyItems.MORTAR.get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getMaterial(ItemStack stack) {
|
||||
return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null;
|
||||
@Nullable
|
||||
public IDesignMaterial getMaterial(ItemStack itemStack) {
|
||||
return (itemStack.getItem() == Item.getItemFromBlock(Botany.gardening().ceramic))
|
||||
? getMaterial(itemStack.getItemDamage())
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,49 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
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;
|
||||
|
||||
public class CeramicTileRecipe implements IRecipe {
|
||||
protected ItemStack cached;
|
||||
import binnie.Constants;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.ceramic.brick.CeramicBrickType;
|
||||
import binnie.botany.gardening.ModuleGardening;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class CeramicTileRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { private ItemStack cached = ItemStack.EMPTY;
|
||||
|
||||
public CeramicTileRecipe() {
|
||||
setRegistryName(new ResourceLocation(Constants.BOTANY_MOD_ID, "ceramic_tile"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
cached = getCraftingResult(crafting);
|
||||
return cached != null;
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
cached = getCraftingResult(inv);
|
||||
return !cached.isEmpty();
|
||||
}
|
||||
|
||||
@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;
|
||||
ModuleGardening gardening = Botany.gardening();
|
||||
Item ceramicBlock = Item.getItemFromBlock(gardening.ceramic);
|
||||
Item ceramicTile = Item.getItemFromBlock(gardening.ceramicTile);
|
||||
Item ceramicBrick = Item.getItemFromBlock(gardening.ceramicBrick);
|
||||
Item mortar = gardening.misc;
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
int ix = -1;
|
||||
int iy = -1;
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
if (!stack.isEmpty()) {
|
||||
int x = i / 3;
|
||||
int y = i % 3;
|
||||
if (ix == -1) {
|
||||
@@ -39,33 +51,35 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
iy = y;
|
||||
}
|
||||
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (item != ceramicBlock && item != ceramicTile && item != ceramicBrick && item != mortar) {
|
||||
return null;
|
||||
if (stack.getItem() != ceramicBlock && stack.getItem() != ceramicTile && stack.getItem() != ceramicBrick && stack.getItem() != mortar) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
|
||||
ItemStack stack2 = type.getRecipe(stacks);
|
||||
if (stack2 != null) {
|
||||
return stack2;
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
ItemStack result = type.getRecipe(stacks);
|
||||
if (!result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
public boolean canFit(int width, int height) {
|
||||
return width >= 2 && height >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return cached;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
||||
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramic(BlockCeramic block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage());
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(itemStack.getItemDamage());
|
||||
return I18N.localise("botany.ceramic.name", color.getDisplayName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
|
||||
public class ItemStainedGlass extends ItemMetadata implements IColoredItem {
|
||||
public ItemStainedGlass(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getItemDamage(stack));
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,46 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.Constants;
|
||||
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.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class PigmentRecipe implements IRecipe {
|
||||
protected ItemStack cached;
|
||||
|
||||
private ItemStack unknown;
|
||||
|
||||
public class PigmentRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
public PigmentRecipe() {
|
||||
unknown = null;
|
||||
setRegistryName(new ResourceLocation(Constants.BOTANY_MOD_ID, "pigment"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
return getCraftingResult(crafting) != null;
|
||||
return !getCraftingResult(crafting).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
return unknown;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = null;
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
|
||||
if (crafting.getStackInSlot(i) != null) {
|
||||
ItemStack stackInSlot = crafting.getStackInSlot(i);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
if (++n > 1) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i));
|
||||
if (flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
if (Binnie.GENETICS.getFlowerRoot().isMember(stackInSlot)) {
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
if (flower != null && flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.gardening().pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +48,7 @@ public class PigmentRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
public boolean canFit(int width, int height) {
|
||||
return width >= 1 && height >= 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
|
||||
public class TileCeramic extends TileEntity {
|
||||
protected EnumFlowerColor color = EnumFlowerColor.Black;
|
||||
|
||||
public EnumFlowerColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(EnumFlowerColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("Color", color.getFlowerColorAllele().getID());
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
color = EnumFlowerColor.VALUES[compound.getInteger("Color")];
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return getStack(1);
|
||||
}
|
||||
|
||||
public ItemStack getStack(int amount) {
|
||||
int ID = 0;
|
||||
if (color != null) {
|
||||
ID = color.getFlowerColorAllele().getID();
|
||||
}
|
||||
return new ItemStack(Botany.gardening().ceramic, amount, ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.properties.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.properties.UnlistedBlockPos;
|
||||
import forestry.core.models.BlockModelEntry;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.ceramic.TileCeramic;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.models.DefaultStateMapper;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.core.models.ModelMutlipass;
|
||||
import binnie.core.util.TileUtil;
|
||||
|
||||
public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicBrickPair>, IColoredBlock, ISpriteRegister, IStateMapperRegister, IItemModelRegister {
|
||||
private static final PropertyEnum<CeramicBrickType> TYPE = PropertyEnum.create("type", CeramicBrickType.class);
|
||||
|
||||
public BlockCeramicBrick() {
|
||||
super(Material.ROCK);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setRegistryName("ceramicBrick");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, @Nullable EntityPlayer player, boolean willHarvest) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
drops = Collections.singletonList(ceramic.getStack());
|
||||
}
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileCeramicBrick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
itemList.add(new CeramicBrickPair(color, color, CeramicBrickType.TILE).getStack(1));
|
||||
}
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
if (type.canDouble()) {
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Gold, type).getStack(1));
|
||||
}
|
||||
}
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Gold, CeramicBrickType.SPLIT).getStack(1));
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Brown, CeramicBrickType.CHEQUERED).getStack(1));
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Brown, CeramicBrickType.LARGE_BRICK).getStack(1));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ResourceLocation resourceLocation = new ResourceLocation(Constants.BOTANY_MOD_ID, "ceramicBrick");
|
||||
ModelLoader.setCustomStateMapper(this, new DefaultStateMapper(resourceLocation));
|
||||
ModelManager.registerCustomBlockModel(new BlockModelEntry(
|
||||
new ModelResourceLocation(resourceLocation, "normal"),
|
||||
new ModelResourceLocation(resourceLocation, "inventory"),
|
||||
new ModelMutlipass<>(BlockCeramicBrick.class),
|
||||
this
|
||||
));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, new CeramicBrickMeshDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(
|
||||
this,
|
||||
new IProperty[]{TYPE},
|
||||
new IUnlistedProperty[]{
|
||||
UnlistedBlockPos.POS,
|
||||
UnlistedBlockAccess.BLOCKACCESS
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(TYPE, CeramicBrickType.VALUES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(TYPE).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return ((IExtendedBlockState) super.getExtendedState(state, world, pos)).withProperty(UnlistedBlockPos.POS, pos).withProperty(UnlistedBlockAccess.BLOCKACCESS, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
||||
ItemStack stack = placer.getHeldItem(hand);
|
||||
CeramicBrickPair pair = new CeramicBrickPair(stack);
|
||||
return getDefaultState().withProperty(TYPE, pair.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(worldIn, pos, TileCeramicBrick.class);
|
||||
if (ceramic != null) {
|
||||
CeramicBrickPair pair = new CeramicBrickPair(stack);
|
||||
ceramic.setColors(pair.colorFirst, pair.colorSecond);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if (ceramic != null) {
|
||||
return ceramic.pair().getStack(0);
|
||||
}
|
||||
return super.getPickBlock(state, target, world, pos, player);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
|
||||
if (world != null && pos != null) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if (ceramic != null) {
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.getColorFirst().getFlowerColorAllele().getColor(false);
|
||||
} else if (tintIndex == 2) {
|
||||
return ceramic.getColorSecond().getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CeramicBrickPair getInventoryKey(ItemStack stack) {
|
||||
return new CeramicBrickPair(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CeramicBrickPair getWorldKey(IBlockState state) {
|
||||
IExtendedBlockState extendedState = (IExtendedBlockState) state;
|
||||
IBlockAccess world = extendedState.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = extendedState.getValue(UnlistedBlockPos.POS);
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if (ceramic != null) {
|
||||
return ceramic.pair();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(CeramicBrickPair type, @Nullable EnumFacing facing, int pass) {
|
||||
return type.getSprite(pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(ITextureManager manager) {
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
type.sprites = new TextureAtlasSprite[3];
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
type.sprites[i] = textureMap.registerSprite(new ResourceLocation(Constants.BOTANY_MOD_ID + ":blocks/ceramic." + type.id + "." + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CeramicBrickMeshDefinition implements ItemMeshDefinition {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "inventory");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class CeramicBrickPair {
|
||||
public static final CeramicBrickPair EMPTY = new CeramicBrickPair(EnumFlowerColor.DarkSeaGreen, EnumFlowerColor.DarkSeaGreen, CeramicBrickType.TILE);
|
||||
|
||||
public final EnumFlowerColor colorFirst;
|
||||
public final EnumFlowerColor colorSecond;
|
||||
|
||||
public CeramicBrickType type;
|
||||
public int ordinal;
|
||||
|
||||
CeramicBrickPair(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
this.type = type;
|
||||
ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair(ItemStack stack) {
|
||||
this(getId(stack));
|
||||
}
|
||||
|
||||
public CeramicBrickPair(int id) {
|
||||
colorFirst = EnumFlowerColor.get(id & 0xFF);
|
||||
colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
type = CeramicBrickType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return type.canDouble() && colorSecond != colorFirst;
|
||||
}
|
||||
|
||||
public static int getId(ItemStack stack){
|
||||
if(!stack.hasTagCompound()){
|
||||
return EMPTY.ordinal();
|
||||
}
|
||||
NBTTagCompound nbtTagCompound = stack.getTagCompound();
|
||||
return nbtTagCompound.getInteger("id");
|
||||
}
|
||||
|
||||
public ItemStack getStack(int i) {
|
||||
ItemStack stack = new ItemStack(Botany.gardening().ceramicBrick, i);
|
||||
stack.setTagInfo("id", new NBTTagInt(ordinal()));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = colorFirst.getFlowerColorAllele().getColorName();
|
||||
if (type.canDouble() && colorSecond != colorFirst) {
|
||||
name = name + " & " + colorSecond.getFlowerColorAllele().getColorName();
|
||||
}
|
||||
return I18N.localise("botany.ceramic.type." + type.id + ".name", name);
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
TextureAtlasSprite[] sprites = type.sprites;
|
||||
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
|
||||
return sprites[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Integer.hashCode(type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CeramicBrickPair
|
||||
&& ((CeramicBrickPair) obj).type == type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
|
||||
public enum CeramicBrickType implements IStringSerializable {
|
||||
TILE("tile") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int mortars = 0;
|
||||
int blocks = 0;
|
||||
int blockColor = -1;
|
||||
for (ItemStack stack : stacks) {
|
||||
if (isMortar(stack)) {
|
||||
++mortars;
|
||||
} else {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.gardening().ceramic)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
++blocks;
|
||||
int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else {
|
||||
if (blockColor != color) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mortars != 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new CeramicBrickPair(c, c, CeramicBrickType.TILE).getStack(3);
|
||||
}
|
||||
},
|
||||
BRICK("brick") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
STRIPE_BRICK("brickstripe") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
LARGE_BRICK("bricklarge") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
ItemStack stack3 = stacks.get(0);
|
||||
CeramicBrickPair type3 = new CeramicBrickPair(stack3);
|
||||
if (type3.type == CeramicBrickType.VERTICAL_LARGE_BRICK) {
|
||||
type3.type = this;
|
||||
return type3.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
if (stacks.size() != 3) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int[] colors = {-1, -1};
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
for (ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.gardening().ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.TILE) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int color5 = type4.colorFirst.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color5;
|
||||
a++;
|
||||
} else if (colors[0] == color5) {
|
||||
a++;
|
||||
} else if (colors[1] == -1) {
|
||||
colors[1] = color5;
|
||||
b++;
|
||||
} else {
|
||||
if (colors[1] != color5) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
b++;
|
||||
}
|
||||
}
|
||||
if (colors[1] == -1) {
|
||||
colors[1] = colors[0];
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LARGE_BRICK).getStack(3);
|
||||
}
|
||||
}
|
||||
},
|
||||
SPLIT("split") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int[] colors = {-1, -1};
|
||||
int altCounter = 0;
|
||||
for (ItemStack stack2 : stacks) {
|
||||
int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.gardening().ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
CeramicBrickPair type = new CeramicBrickPair(stack2);
|
||||
if (type.type != CeramicBrickType.TILE) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int color2 = type.colorFirst.ordinal();
|
||||
if (colors[alt] == -1) {
|
||||
colors[alt] = color2;
|
||||
} else if (colors[alt] != color2) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
++altCounter;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.SPLIT).getStack(4);
|
||||
}
|
||||
},
|
||||
CHEQUERED("cheque") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.gardening().ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.type != CeramicBrickType.SPLIT) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int color3 = type2.colorFirst.ordinal();
|
||||
int color4 = type2.colorSecond.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
colors[1] = color4;
|
||||
} else {
|
||||
if (colors[0] != color3 || colors[1] != color4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.CHEQUERED).getStack(4);
|
||||
}
|
||||
},
|
||||
MIXED("mixed") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.gardening().ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.isTwoColors()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
int color3 = type2.colorFirst.ordinal();
|
||||
if (type2.type == CeramicBrickType.SPLIT) {
|
||||
if (colors[1] != -1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
colors[1] = color3;
|
||||
} else {
|
||||
if (type2.type != CeramicBrickType.CHEQUERED) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
} else if (colors[0] != color3) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
int color4 = type2.colorSecond.ordinal();
|
||||
}
|
||||
if (colors[0] == -1 || colors[1] == -1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.MIXED).getStack(4);
|
||||
}
|
||||
},
|
||||
VERTICAL_BRICK("verticalbrick") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VERTICAL_STRIPE_BRICK("verticalbrickstripe") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VERTICAL_LARGE_BRICK("verticalbricklarge") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
};
|
||||
|
||||
public static final CeramicBrickType[] VALUES = values();
|
||||
|
||||
public String id;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
TextureAtlasSprite[] sprites;
|
||||
|
||||
CeramicBrickType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static CeramicBrickType get(int id) {
|
||||
return VALUES[id % VALUES.length];
|
||||
}
|
||||
|
||||
public boolean canDouble() {
|
||||
return this != CeramicBrickType.TILE;
|
||||
}
|
||||
|
||||
public abstract ItemStack getRecipe(List<ItemStack> stacks);
|
||||
|
||||
protected ItemStack getVerticalBrickRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
ItemStack stack5 = stacks.get(0);
|
||||
CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.LARGE_BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_LARGE_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == CeramicBrickType.BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == CeramicBrickType.STRIPE_BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_STRIPE_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
ItemStack stack5 = stacks.get(0);
|
||||
CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.VERTICAL_BRICK) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
|
||||
if (type.type == CeramicBrickType.STRIPE_BRICK) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else if (stacks.size() == 4) {
|
||||
int[] colors = {-1, -1};
|
||||
for (int index2 = 0; index2 < stacks.size(); ++index2) {
|
||||
ItemStack stack4 = stacks.get(index2);
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.gardening().ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.LARGE_BRICK) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
int color5 = type4.colorFirst.ordinal();
|
||||
int color6 = type4.colorSecond.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (ceramicType == CeramicBrickType.STRIPE_BRICK) {
|
||||
alt2 = 0;
|
||||
}
|
||||
|
||||
if (colors[alt2] == -1) {
|
||||
colors[alt2] = color5;
|
||||
colors[1 - alt2] = color6;
|
||||
} else if (colors[alt2] != color5 || colors[1 - alt2] != color6) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), ceramicType).getStack(4);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
protected boolean isMortar(ItemStack stack) {
|
||||
return stack.getItem() == Botany.gardening().misc && stack.getItemDamage() == BotanyItems.MORTAR.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramicBrick(BlockCeramicBrick block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack);
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.colorFirst.getFlowerColorAllele().getColor(false);
|
||||
} else if (tintIndex == 2) {
|
||||
return ceramic.colorSecond.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return new CeramicBrickPair(itemStack).getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
|
||||
public class TileCeramicBrick extends TileEntity {
|
||||
private EnumFlowerColor colorFirst = EnumFlowerColor.Black;
|
||||
private EnumFlowerColor colorSecond = EnumFlowerColor.White;
|
||||
|
||||
public void setColors(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
}
|
||||
|
||||
public boolean hasTwoColors() {
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && colorSecond != colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(int i) {
|
||||
ItemStack s = TileEntityMetadata.getItemStack(Botany.gardening().ceramicBrick, ordinal());
|
||||
s.setCount(i);
|
||||
return s;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return colorFirst.ordinal() + colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair pair() {
|
||||
return new CeramicBrickPair(colorFirst, colorSecond, CeramicBrickType.VALUES[getBlockMetadata()]);
|
||||
}
|
||||
|
||||
public EnumFlowerColor getColorFirst() {
|
||||
return colorFirst;
|
||||
}
|
||||
|
||||
public EnumFlowerColor getColorSecond() {
|
||||
return colorSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("First", colorFirst.ordinal());
|
||||
compound.setInteger("Second", colorSecond.ordinal());
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
return writeToNBT(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
if (compound.hasKey("First")) {
|
||||
colorFirst = EnumFlowerColor.VALUES[compound.getInteger("First")];
|
||||
}
|
||||
|
||||
if (compound.hasKey("Second")) {
|
||||
colorSecond = EnumFlowerColor.VALUES[compound.getInteger("Second")];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,12 +1,25 @@
|
||||
package binnie.botany.core;
|
||||
|
||||
import binnie.botany.api.FlowerManager;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.genetics.FlowerHelper;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.botany.genetics.FlowerRoot;
|
||||
|
||||
public class BotanyCore {
|
||||
public static IFlowerRoot speciesRoot = new FlowerHelper();
|
||||
public static final int CHANCE_INTERPOLLINATION = 20;
|
||||
|
||||
public static IFlowerRoot getFlowerRoot() {
|
||||
return BotanyCore.speciesRoot;
|
||||
if (FlowerManager.flowerRoot == null) {
|
||||
FlowerManager.flowerRoot = new FlowerRoot();
|
||||
}
|
||||
return FlowerManager.flowerRoot;
|
||||
}
|
||||
|
||||
public static IGardeningManager getGardening() {
|
||||
if (FlowerManager.gardening == null) {
|
||||
FlowerManager.gardening = new Gardening();
|
||||
}
|
||||
return FlowerManager.gardening;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,33 @@
|
||||
package binnie.botany.core;
|
||||
|
||||
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.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import binnie.botany.gui.database.WindowBotanistDatabase;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.gui.minecraft.Window;
|
||||
|
||||
public enum BotanyGUI implements IBinnieGUID {
|
||||
Database,
|
||||
DatabaseNEI;
|
||||
DATABASE,
|
||||
DATABASE_NEI;
|
||||
|
||||
@Override
|
||||
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
|
||||
Window window = null;
|
||||
TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
IInventory object = null;
|
||||
if (tileEntity instanceof IInventory) {
|
||||
object = (IInventory) tileEntity;
|
||||
}
|
||||
switch (this) {
|
||||
case Database:
|
||||
case DatabaseNEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
|
||||
case DATABASE:
|
||||
case DATABASE_NEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.DATABASE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.core;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,43 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(IFlowerColor value) {
|
||||
this.value = 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 getTooltip(Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
tooltip.add(value.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(IColourMix value, int y) {
|
||||
return new ControlColorMixItem(getContent(), value, y);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Resultant,
|
||||
Further
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
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);
|
||||
|
||||
if (getValue() != null) {
|
||||
itemWidget1.setValue(getValue().getColor1());
|
||||
itemWidget2.setValue(getValue().getColor2());
|
||||
itemWidget3.setValue(getValue().getResult());
|
||||
addSymbol.setValue(getValue());
|
||||
arrowSymbol.setValue(getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.craftgui.controls.listbox.ControlTextOption;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITextureSheet;
|
||||
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 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (type == 0) {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
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,36 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
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);
|
||||
}
|
||||
|
||||
@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,36 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
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);
|
||||
}
|
||||
|
||||
@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,108 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageSpecies;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.core.util.I18N;
|
||||
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;
|
||||
}
|
||||
|
||||
IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IFlowerGenome genome = tree.getGenome();
|
||||
IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
|
||||
int w = 144;
|
||||
int h = 176;
|
||||
|
||||
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);
|
||||
|
||||
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.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.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.fertility"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getFertility() + "x", 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.nectar"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), 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;
|
||||
}
|
||||
}
|
||||
|
||||
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,91 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.IDatabaseMode;
|
||||
import binnie.core.craftgui.database.PageBranchOverview;
|
||||
import binnie.core.craftgui.database.PageBranchSpecies;
|
||||
import binnie.core.craftgui.database.PageBreeder;
|
||||
import binnie.core.craftgui.database.PageSpeciesClassification;
|
||||
import binnie.core.craftgui.database.PageSpeciesMutations;
|
||||
import binnie.core.craftgui.database.PageSpeciesOverview;
|
||||
import binnie.core.craftgui.database.PageSpeciesResultant;
|
||||
import binnie.core.craftgui.database.WindowAbstractDatabase;
|
||||
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);
|
||||
}
|
||||
|
||||
@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 AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("botany.gui.database.name");
|
||||
}
|
||||
|
||||
enum FlowerMode implements IDatabaseMode {
|
||||
COLOR;
|
||||
|
||||
@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,74 +1,63 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.core.circuits.BinnieCircuit;
|
||||
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;
|
||||
private GardenLogic logic;
|
||||
|
||||
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;
|
||||
public CircuitGarden(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) {
|
||||
super(getName(moisture, ph, manual, fertilised), 4, getLayout(manual), recipe);
|
||||
isManual = manual;
|
||||
isFertilised = fertilised;
|
||||
acidity = ph;
|
||||
String info = "";
|
||||
|
||||
if (moisture == EnumMoisture.DRY) {
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.moisture.dry")
|
||||
+ EnumChatFormatting.RESET;
|
||||
logic = new GardenLogic(moisture, ph, isManual, fertilised, icon, I18N.localise(getUnlocalizedName()));
|
||||
String info = I18N.localise("botany.moisture") + ": " + moisture.getLocalisedName(true);
|
||||
if (ph != null) {
|
||||
info += TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true);
|
||||
}
|
||||
String fertilizedKey = fertilised ? "for.binnie.circuit.garden.fertilized" : "for.binnie.circuit.garden.unfertilized";
|
||||
info += TextFormatting.GRAY + " " + I18N.localise(fertilizedKey);
|
||||
addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info));
|
||||
}
|
||||
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.moisture.damp")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
private static ICircuitLayout getLayout(boolean manual) {
|
||||
String layoutUid = manual ? "forestry.farms.manual" : "forestry.farms.managed";
|
||||
ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout(layoutUid);
|
||||
Preconditions.checkState(layout != null, "Couldn't find Forestry circuit layout %s.", layoutUid);
|
||||
return layout;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.ACID) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.RED
|
||||
+ I18N.localise("botany.ph.acid")
|
||||
+ EnumChatFormatting.RESET;
|
||||
private static String getName(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised) {
|
||||
String name = "garden." + moisture.getName();
|
||||
if (ph != null) {
|
||||
name += "." + ph.getName();
|
||||
}
|
||||
if (manual) {
|
||||
name += ".manual";
|
||||
}
|
||||
if (fertilised) {
|
||||
name += ".fert";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.NEUTRAL) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.GREEN
|
||||
+ I18N.localise("botany.ph.neutral")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.ALKALINE) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.AQUA
|
||||
+ I18N.localise("botany.ph.alkaline")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
if (info.length() > 0) {
|
||||
info = " (" + info + EnumChatFormatting.RESET + ")";
|
||||
}
|
||||
addTooltipString("Flowers" + info);
|
||||
public CircuitGarden setManual() {
|
||||
isManual = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,15 +65,24 @@ public class CircuitGarden extends BinnieCircuit {
|
||||
return tile instanceof IFarmHousing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IFarmHousing getCircuitable(Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return null;
|
||||
}
|
||||
return (IFarmHousing) tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertion(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
IFarmHousing housing = getCircuitable(tile);
|
||||
if (housing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GardenLogic logic = new GardenLogic((IFarmHousing) tile);
|
||||
logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName()));
|
||||
((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic);
|
||||
logic.setManual(isManual);
|
||||
|
||||
housing.setFarmLogic(FarmDirection.values()[slot], logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,14 +92,16 @@ public class CircuitGarden extends BinnieCircuit {
|
||||
|
||||
@Override
|
||||
public void onRemoval(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
IFarmHousing farmHousing = getCircuitable(tile);
|
||||
if (farmHousing == null) {
|
||||
return;
|
||||
}
|
||||
((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]);
|
||||
|
||||
farmHousing.resetFarmLogic(FarmDirection.values()[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int arg0, Object arg1) {
|
||||
public void onTick(int slot, Object tile) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,16 @@
|
||||
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.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
protected World world;
|
||||
protected IFarmHousing housing;
|
||||
protected boolean isManual;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
|
||||
public FarmLogic(IFarmHousing housing) {
|
||||
this.housing = housing;
|
||||
}
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
boolean isManual;
|
||||
|
||||
@Override
|
||||
public IFarmLogic setManual(boolean flag) {
|
||||
@@ -24,35 +18,32 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean isAirBlock(Vect position) {
|
||||
return world.isAirBlock(position.x, position.y, position.z);
|
||||
protected final boolean isAirBlock(World world, BlockPos pos) {
|
||||
return world.isAirBlock(pos);
|
||||
}
|
||||
|
||||
protected boolean isWaterBlock(Vect position) {
|
||||
return world.getBlock(position.x, position.y, position.z) == Blocks.water;
|
||||
protected final IBlockState getBlockState(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
protected Block getBlock(Vect position) {
|
||||
return world.getBlock(position.x, position.y, position.z);
|
||||
protected final Block getBlock(World world, BlockPos pos) {
|
||||
return getBlockState(world, pos).getBlock();
|
||||
}
|
||||
|
||||
protected int getBlockMeta(Vect position) {
|
||||
return world.getBlockMetadata(position.x, position.y, position.z);
|
||||
protected final int getBlockMeta(World world, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return blockState.getBlock().getMetaFromState(blockState);
|
||||
}
|
||||
|
||||
protected ItemStack getAsItemStack(Vect position) {
|
||||
return new ItemStack(getBlock(position), 1, getBlockMeta(position));
|
||||
protected final ItemStack getAsItemStack(World world, BlockPos position) {
|
||||
return new ItemStack(getBlock(world, position), 1, getBlockMeta(world, position));
|
||||
}
|
||||
|
||||
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 final boolean isWaterBlock(World world, BlockPos pos) {
|
||||
return getBlock(world, pos) == Blocks.WATER;
|
||||
}
|
||||
|
||||
protected void setBlock(Vect position, Block block, int meta) {
|
||||
world.setBlock(position.x, position.y, position.z, block, meta, 2);
|
||||
protected final void setBlock(World world, BlockPos pos, Block block, int meta) {
|
||||
world.setBlockState(pos, block.getStateFromMeta(meta), 2);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,54 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
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;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
|
||||
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;
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos) == Botany.flower;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICrop getCropAt(World world, int x, int y, int z) {
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
IFlower flower = null;
|
||||
if (world.getTileEntity(pos) instanceof TileEntityFlower) {
|
||||
flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
|
||||
}
|
||||
|
||||
// TODO Look at TileEntityFlower::onShear logic
|
||||
if (flower != null && flower.getAge() > 1) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER);
|
||||
ItemStack seed = flowerRoot.getMemberStack(flower, EnumFlowerStage.SEED);
|
||||
if (mature != null && seed != null) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
return new FlowerCrop(pos, mature, seed);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack);
|
||||
EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack);
|
||||
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
|
||||
}
|
||||
|
||||
@@ -34,9 +58,10 @@ public class FarmableFlower implements IFarmable {
|
||||
}
|
||||
|
||||
@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());
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getMember(germling);
|
||||
flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
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.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class FarmableVanillaFlower extends FarmableFlower {
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
@@ -14,8 +16,9 @@ public class FarmableVanillaFlower extends FarmableFlower {
|
||||
}
|
||||
|
||||
@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 boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(germling);
|
||||
return flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
|
||||
public class FlowerCrop implements ICrop {
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
BlockPos position;
|
||||
|
||||
public FlowerCrop(BlockPos pos, ItemStack... drops) {
|
||||
Collections.addAll(this.drops, drops);
|
||||
position = pos;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NonNullList<ItemStack> harvest() {
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPosition() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,13 @@
|
||||
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 javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -24,30 +15,53 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.owner.IOwnedTile;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
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.IBlockSoil;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.core.liquid.ManagerLiquid;
|
||||
|
||||
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;
|
||||
|
||||
List<IFarmable> farmables;
|
||||
private EnumMoisture moisture;
|
||||
@Nullable
|
||||
private EnumAcidity acidity;
|
||||
private boolean fertilised;
|
||||
private String name;
|
||||
private NonNullList<ItemStack> produce;
|
||||
private ItemStack icon;
|
||||
|
||||
public GardenLogic(IFarmHousing housing) {
|
||||
super(housing);
|
||||
produce = new ArrayList<>();
|
||||
public GardenLogic(EnumMoisture moisture2, @Nullable EnumAcidity acidity2, boolean isManual, boolean isFertilised, ItemStack icon2, String name2) {
|
||||
this.isManual = isManual;
|
||||
produce = NonNullList.create();
|
||||
farmables = new ArrayList<>();
|
||||
farmables.add(new FarmableFlower());
|
||||
farmables.add(new FarmableVanillaFlower());
|
||||
|
||||
moisture = moisture2;
|
||||
acidity = acidity2;
|
||||
fertilised = isFertilised;
|
||||
icon = icon2;
|
||||
name = name2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,81 +75,83 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
|
||||
@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);
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
return gardening.isSoil(itemstack.getItem()) ||
|
||||
itemstack.getItem() == Item.getItemFromBlock(Blocks.SAND) ||
|
||||
itemstack.getItem() == Item.getItemFromBlock(Blocks.DIRT) ||
|
||||
gardening.isAcidFertiliser(itemstack) ||
|
||||
gardening.isAlkalineFertiliser(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> collect() {
|
||||
Collection<ItemStack> products = produce;
|
||||
produce = new ArrayList<>();
|
||||
public NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
|
||||
NonNullList<ItemStack> products = produce;
|
||||
produce = NonNullList.create();
|
||||
return products;
|
||||
}
|
||||
|
||||
@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);
|
||||
public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
return maintainSoil(world, pos, direction, extent, farmHousing) ||
|
||||
(!isManual && maintainWater(world, pos, direction, extent, farmHousing)) ||
|
||||
maintainCrops(world, pos.up(), direction, extent, farmHousing);
|
||||
}
|
||||
|
||||
private boolean isWaste(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(Blocks.dirt);
|
||||
return stack.getItem() == Item.getItemFromBlock(Blocks.DIRT);
|
||||
}
|
||||
|
||||
private boolean maintainSoil(int x2, int y2, int z2, FarmDirection direction, int extent) {
|
||||
private boolean maintainSoil(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
Vect position = translateWithOffset(x2, y2, z2, direction, i);
|
||||
if (fertilised && Gardening.isSoil(world.getBlock(position.x, position.y, position.z))) {
|
||||
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
|
||||
if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (fertilised && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
if (soil.fertilise(world, position, EnumSoilType.FLOWERBED)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) {
|
||||
world.setBlockToAir(position.x, position.y + 1, position.z);
|
||||
if (getBlock(world, position.up()) == Botany.gardening().plant) {
|
||||
world.setBlockToAir(position.up());
|
||||
} else {
|
||||
if (acidity != null && Gardening.isSoil(world.getBlock(position.x, position.y, position.z))) {
|
||||
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
|
||||
EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z);
|
||||
if (acidity != null && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
EnumAcidity pH = soil.getPH(world, position);
|
||||
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});
|
||||
ItemStack stack = getAvailableAlkaline(housing);
|
||||
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() + 1])) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
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});
|
||||
ItemStack stack = getAvailableAcid(housing);
|
||||
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() - 1])) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
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);
|
||||
if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack block = getAsItemStack(world, position);
|
||||
ItemStack loam = getAvailableLoam(housing);
|
||||
if (isWaste(block) && !loam.isEmpty()) {
|
||||
produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0));
|
||||
setBlock(world, position, Blocks.AIR, 0);
|
||||
return trySetSoil(world, position, loam, housing);
|
||||
}
|
||||
} else if (!isManual) {
|
||||
if (!isWaterBlock(position)) {
|
||||
if (!isWaterBlock(world, position)) {
|
||||
if (i % 2 == 0) {
|
||||
return trySetSoil(position);
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
|
||||
FarmDirection cclock = FarmDirection.EAST;
|
||||
if (direction == FarmDirection.EAST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
@@ -144,11 +160,10 @@ public class GardenLogic extends FarmLogic {
|
||||
} else if (direction == FarmDirection.WEST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
}
|
||||
|
||||
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
|
||||
ItemStack soil2 = getAsItemStack(previous);
|
||||
if (!Gardening.isSoil(soil2.getItem())) {
|
||||
trySetSoil(position);
|
||||
BlockPos previous = position.offset(cclock.getFacing());
|
||||
ItemStack soil2 = getAsItemStack(world, previous);
|
||||
if (!gardening.isSoil(soil2.getItem())) {
|
||||
trySetSoil(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,127 +172,136 @@ public class GardenLogic extends FarmLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
private boolean maintainWater(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
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)) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isWaterBlock(position)) {
|
||||
if (isWaterBlock(world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean isEnclosed = true;
|
||||
if (world.isAirBlock(position.x + 1, position.y, position.z)) {
|
||||
if (world.isAirBlock(position.east())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x - 1, position.y, position.z)) {
|
||||
} else if (world.isAirBlock(position.west())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x, position.y, position.z + 1)) {
|
||||
} else if (world.isAirBlock(position.south())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x, position.y, position.z - 1)) {
|
||||
} else if (world.isAirBlock(position.north())) {
|
||||
isEnclosed = false;
|
||||
}
|
||||
|
||||
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
|
||||
if (isEnclosed) {
|
||||
return trySetWater(position);
|
||||
return trySetWater(world, position, housing);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ItemStack getAvailableLoam() {
|
||||
private ItemStack getAvailableLoam(IFarmHousing housing) {
|
||||
EnumMoisture[] moistures;
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DRY
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DRY
|
||||
};
|
||||
} else if (moisture == EnumMoisture.DRY) {
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.DRY
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.DRY
|
||||
};
|
||||
} else {
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DAMP
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DAMP
|
||||
};
|
||||
}
|
||||
|
||||
EnumAcidity[] acidities = {
|
||||
EnumAcidity.NEUTRAL,
|
||||
EnumAcidity.ACID,
|
||||
EnumAcidity.ALKALINE
|
||||
EnumAcidity.NEUTRAL,
|
||||
EnumAcidity.ACID,
|
||||
EnumAcidity.ALKALINE
|
||||
};
|
||||
|
||||
for (EnumMoisture moist : moistures) {
|
||||
for (EnumAcidity acid : acidities) {
|
||||
for (Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) {
|
||||
for (Block type : new Block[]{Botany.gardening().flowerbed, Botany.gardening().loam, Botany.gardening().soil}) {
|
||||
int meta = acid.ordinal() * 3 + moist.ordinal();
|
||||
ItemStack[] resource = {new ItemStack(type, 1, meta)};
|
||||
if (housing.getFarmInventory().hasResources(resource)) {
|
||||
return resource[0];
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
ItemStack resourceStack = new ItemStack(type, 1, meta);
|
||||
resources.add(resourceStack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return resourceStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (housing.getFarmInventory().hasResources(new ItemStack[]{new ItemStack(Blocks.dirt)})) {
|
||||
return new ItemStack(Blocks.dirt);
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
ItemStack resourceStack = new ItemStack(Blocks.DIRT);
|
||||
resources.add(resourceStack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return new ItemStack(Blocks.DIRT);
|
||||
}
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private boolean trySetSoil(Vect position) {
|
||||
return trySetSoil(position, getAvailableLoam());
|
||||
private boolean trySetSoil(World world, BlockPos position, IFarmHousing housing) {
|
||||
return trySetSoil(world, position, getAvailableLoam(housing), housing);
|
||||
}
|
||||
|
||||
private boolean trySetSoil(Vect position, ItemStack loam) {
|
||||
private boolean trySetSoil(World world, BlockPos position, ItemStack loam, IFarmHousing housing) {
|
||||
ItemStack copy = loam;
|
||||
if (loam == null) {
|
||||
if (loam.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
|
||||
loam = new ItemStack(Botany.soil, 0, 4);
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
|
||||
loam = new ItemStack(Botany.gardening().soil, 1, 4);
|
||||
}
|
||||
|
||||
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
|
||||
housing.getFarmInventory().removeResources(new ItemStack[]{copy});
|
||||
setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage());
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(copy);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean trySetWater(Vect position) {
|
||||
FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
|
||||
private boolean trySetWater(World world, BlockPos position, IFarmHousing housing) {
|
||||
FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000);
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
if (!housing.hasLiquid(water)) {
|
||||
if (water == null || !housing.hasLiquid(water)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setBlock(position, Blocks.water, 0);
|
||||
setBlock(world, position, Blocks.WATER, 0);
|
||||
housing.removeLiquid(water);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (moisture != EnumMoisture.DRY) {
|
||||
return trySetSoil(position);
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
|
||||
ItemStack[] sand = {new ItemStack(Blocks.sand, 1)};
|
||||
if (!housing.getFarmInventory().hasResources(sand)) {
|
||||
ItemStack sand = new ItemStack(Blocks.SAND, 1);
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(sand);
|
||||
if (!housing.getFarmInventory().hasResources(resources)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setBlock(position, Blocks.sand, 0);
|
||||
housing.getFarmInventory().removeResources(sand);
|
||||
setBlock(world, position, Blocks.SAND, 0);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setIcon(ItemStack icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedGermling(ItemStack itemstack) {
|
||||
for (IFarmable farmable : farmables) {
|
||||
@@ -289,23 +313,17 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
return null;
|
||||
public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
|
||||
if (isManual) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up())))
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return icon.getIconIndex();
|
||||
}
|
||||
|
||||
public void setIcon(ItemStack icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getSpriteSheet() {
|
||||
return TextureMap.locationBlocksTexture;
|
||||
public ResourceLocation getTextureMap() {
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,67 +331,68 @@ public class GardenLogic extends FarmLogic {
|
||||
return name;
|
||||
}
|
||||
|
||||
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
protected boolean maintainCrops(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
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);
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack below = getAsItemStack(world, position.down());
|
||||
if (gardening.isSoil(below.getItem())) {
|
||||
return trySetCrop(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean trySetCrop(Vect position) {
|
||||
private boolean trySetCrop(World world, BlockPos position, IFarmHousing housing) {
|
||||
for (IFarmable farmable : farmables) {
|
||||
boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z);
|
||||
if (!success || !(housing instanceof IOwnable)) {
|
||||
if (!housing.plantGermling(farmable, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z);
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
return true;
|
||||
}
|
||||
if (housing instanceof IOwnedTile) {
|
||||
TileEntity tile = world.getTileEntity(position);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
IOwnedTile owned = (IOwnedTile) housing;
|
||||
|
||||
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
|
||||
flower.setOwner(owned.getOwnerHandler().getOwner());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAcid() {
|
||||
for (ItemStack stack : Gardening.getAcidFertilisers()) {
|
||||
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) {
|
||||
return stack;
|
||||
public ItemStack getAvailableAcid(IFarmHousing housing) {
|
||||
for (ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAlkaline() {
|
||||
for (ItemStack stack : Gardening.getAlkalineFertilisers()) {
|
||||
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) {
|
||||
return stack;
|
||||
public ItemStack getAvailableAlkaline(IFarmHousing housing) {
|
||||
for (ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
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;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.farm;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,220 +1,320 @@
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
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;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RendererBotany.renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (EnumFlowerType type : EnumFlowerType.values()) {
|
||||
type.registerIcons(register);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFlower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
@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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return (RendererBotany.pass == 1) ?
|
||||
flower.getPetalIcon(stage, flowered, section) :
|
||||
flower.getVariantIcon(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||
return super.canPlaceBlockAt(world, x, y, z)
|
||||
&& canBlockStay(world, x, y, z);
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block block) {
|
||||
return block == Blocks.grass
|
||||
|| block == Blocks.dirt
|
||||
|| block == Blocks.farmland
|
||||
|| Gardening.isSoil(block);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
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 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 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 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;
|
||||
}
|
||||
}
|
||||
package binnie.botany.flower;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.botany.genetics.FlowerDefinition;
|
||||
import binnie.botany.network.PacketID;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.network.packet.MessageNBT;
|
||||
import binnie.core.util.TileUtil;
|
||||
|
||||
public class BlockFlower extends BlockContainer implements IColoredBlock, IStateMapperRegister {
|
||||
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D);
|
||||
/* PROPERTIES */
|
||||
public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class);
|
||||
public static final PropertyInteger SECTION = PropertyInteger.create("section", 0, EnumFlowerType.highestSection - 1);
|
||||
public static final PropertyBool FLOWERED = PropertyBool.create("flowered");
|
||||
public static final PropertyBool SEED = PropertyBool.create("seed");
|
||||
|
||||
public BlockFlower() {
|
||||
super(Material.PLANTS);
|
||||
setTickRandomly(true);
|
||||
setRegistryName("flower");
|
||||
setSoundType(SoundType.PLANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFlower();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
ModelLoader.setCustomStateMapper(this, new StateMapperFlower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (heldItem.isEmpty() || heldItem.getItem() != BinnieCore.getFieldKit() || !player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntityFlower tileFlower = (TileEntityFlower) tile;
|
||||
IFlower flower = tileFlower.getFlower();
|
||||
if (flower == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IFlowerGenome flowerGenome = flower.getGenome();
|
||||
NBTTagCompound info = new NBTTagCompound();
|
||||
info.setString("Species", flowerGenome.getPrimary().getUID());
|
||||
info.setString("Species2", flowerGenome.getSecondary().getUID());
|
||||
info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan());
|
||||
info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID());
|
||||
info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID());
|
||||
info.setBoolean("Wilting", flower.isWilted());
|
||||
info.setBoolean("Flowered", flower.hasFlowered());
|
||||
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player);
|
||||
heldItem.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
TileEntity tile = source.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (flower.getType().getSections() > 1) {
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
}
|
||||
return FLOWER_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (flower.getType().getSections() > 1) {
|
||||
return FULL_BLOCK_AABB.offset(pos);
|
||||
}
|
||||
}
|
||||
return FLOWER_BLOCK_AABB.offset(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
TileEntity flower = world.getTileEntity(pos);
|
||||
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
IFlower f = flowerRoot.getMember(stack);
|
||||
if (f != null) {
|
||||
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity below = world.getTileEntity(pos.down());
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
if (below instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
|
||||
} else {
|
||||
GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
|
||||
((TileEntityFlower) flower).create(stack, owner);
|
||||
}
|
||||
}
|
||||
flowerRoot.tryGrowSection(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
|
||||
if (world != null && pos != null) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (tintIndex == 0) {
|
||||
return flower.getStemColour();
|
||||
} else if (tintIndex == 1) {
|
||||
return flower.getPrimaryColour();
|
||||
}
|
||||
return flower.getSecondaryColour();
|
||||
}
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, BlockPos pos) {
|
||||
return super.canPlaceBlockAt(world, pos) && canBlockStay(world, pos);
|
||||
}
|
||||
|
||||
public boolean canBlockStay(World world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
IBlockState downState = world.getBlockState(pos.down());
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
|
||||
return downState.getBlock() == Botany.flower;
|
||||
}
|
||||
return canPlaceBlockOn(downState.getBlock());
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block block) {
|
||||
return block == Blocks.GRASS
|
||||
|| block == Blocks.DIRT
|
||||
|| block == Blocks.FARMLAND
|
||||
|| BotanyCore.getGardening().isSoil(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumOffsetType getOffsetType() {
|
||||
return EnumOffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
|
||||
if (flower != null && flower.getType() != null) {
|
||||
state = state.withProperty(FLOWER, flower.getType());
|
||||
state = state.withProperty(FLOWERED, flower.isFlowered());
|
||||
state = state.withProperty(SECTION, flower.getRenderSection());
|
||||
state = state.withProperty(SEED, flower.getAge() == 0);
|
||||
} else {
|
||||
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
|
||||
state = state.withProperty(FLOWERED, false);
|
||||
state = state.withProperty(SEED, false);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION, SEED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
checkAndDropBlock(worldIn, pos);
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (flower.getSection() == 0 && flower.getFlower() != null && flower.getFlower().getAge() > 0 && flower.getFlower().getGenome().getPrimary().getType().getSections() > 1 && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) {
|
||||
dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) tile).randomUpdate(rand);
|
||||
checkAndDropBlock(world, pos);
|
||||
return;
|
||||
}
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(World world, BlockPos pos) {
|
||||
if (!canBlockStay(world, pos)) {
|
||||
dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
|
||||
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
|
||||
if (!flower.isEmpty()) {
|
||||
drops.add(flower);
|
||||
}
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
List<ItemStack> drops = getDrops(world, pos, world.getBlockState(pos), 0);
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumTubeInsulate {
|
||||
CLAY(0xa1aacc, "clay"),
|
||||
COBBLE(0x7b7b7b, "cobblestone"),
|
||||
SAND(0xefeab5, "sandstone"),
|
||||
HARDENED_CLAY(0x935c43, "hardened_clay"),
|
||||
STONE(0x6d6d6d, "stone"),
|
||||
SANDSTONE(0xc1b989, "sandstone");
|
||||
|
||||
public static final EnumTubeInsulate[] VALUES = values();
|
||||
|
||||
int color;
|
||||
String uid;
|
||||
|
||||
EnumTubeInsulate(int color, String uid) {
|
||||
this.color = color;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public static EnumTubeInsulate get(int meta) {
|
||||
return VALUES[meta / 128 % VALUES.length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.tube.insulate." + uid + ".name");
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
switch (this) {
|
||||
case CLAY:
|
||||
return new ItemStack(Blocks.CLAY);
|
||||
|
||||
case COBBLE:
|
||||
return new ItemStack(Blocks.COBBLESTONE);
|
||||
|
||||
case HARDENED_CLAY:
|
||||
return new ItemStack(Blocks.HARDENED_CLAY);
|
||||
|
||||
case SAND:
|
||||
return new ItemStack(Blocks.SAND);
|
||||
|
||||
case SANDSTONE:
|
||||
return new ItemStack(Blocks.SANDSTONE);
|
||||
|
||||
case STONE:
|
||||
return new ItemStack(Blocks.STONE);
|
||||
}
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumTubeMaterial {
|
||||
COPPER(0xe3b78e, "copper"),
|
||||
TIN(0xe1eef4, "tin"),
|
||||
BRONZE(0xddc276, "bronze"),
|
||||
IRON(0xd8d8d8, "iron");
|
||||
|
||||
public static final EnumTubeMaterial[] VALUES = values();
|
||||
|
||||
int color;
|
||||
String uid;
|
||||
|
||||
EnumTubeMaterial(int color, String uid) {
|
||||
this.color = color;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public static EnumTubeMaterial get(int meta) {
|
||||
return VALUES[meta % VALUES.length];
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.tube.material." + uid + ".name");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.core.resource.BinnieSprite;
|
||||
|
||||
public class FlowerSpriteManager {
|
||||
private static final Map<IFlowerType, FlowerSprites> flowerSprites = new HashMap<>();
|
||||
|
||||
public static void initSprites(IFlowerType type) {
|
||||
if (flowerSprites.containsKey(type)) {
|
||||
return;
|
||||
}
|
||||
flowerSprites.put(type, new FlowerSprites(type));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getStem(IFlowerType type, int section, boolean flowered) {
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if (flower == null) {
|
||||
return null;
|
||||
}
|
||||
return flower.getStem(type, section, flowered);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered) {
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if (flower == null) {
|
||||
return null;
|
||||
}
|
||||
return flower.getPetal(type, section, flowered);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered) {
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if (flower == null) {
|
||||
return null;
|
||||
}
|
||||
return flower.getVariant(type, section, flowered);
|
||||
}
|
||||
|
||||
private static class FlowerSprites {
|
||||
private BinnieSprite[] stem;
|
||||
private BinnieSprite[] variant;
|
||||
private BinnieSprite[] petal;
|
||||
private BinnieSprite[] unflowered;
|
||||
private int sections;
|
||||
|
||||
public FlowerSprites(IFlowerType type) {
|
||||
sections = type.getSections();
|
||||
stem = new BinnieSprite[sections];
|
||||
petal = new BinnieSprite[sections];
|
||||
variant = new BinnieSprite[sections];
|
||||
unflowered = new BinnieSprite[sections];
|
||||
for (int section = 0; section < sections; ++section) {
|
||||
String suf = (section == 0) ? "" : ("" + (section + 1));
|
||||
String pre = (sections == 1) ? "" : "double/";
|
||||
stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0");
|
||||
petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1");
|
||||
variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2");
|
||||
unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3");
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getStem(IFlowerType type, int section, boolean flowered) {
|
||||
return stem[section % sections].getSprite();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered) {
|
||||
return (flowered ? petal[section % sections] : unflowered[section % sections]).getSprite();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered) {
|
||||
return flowered ? variant[section % sections].getSprite() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,69 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.botany.genetics.Flower;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
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 class ItemBotany extends Item implements IColoredItem, IItemModelRegister {
|
||||
private EnumFlowerStage type;
|
||||
private String tag;
|
||||
|
||||
public abstract class ItemBotany extends Item {
|
||||
public ItemBotany(String name) {
|
||||
public ItemBotany(String name, EnumFlowerStage type, String tag) {
|
||||
this.type = type;
|
||||
this.tag = tag;
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return false;
|
||||
@@ -61,229 +80,187 @@ public abstract class ItemBotany extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
public boolean hasEffect(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IIndividual individual = getIndividual(stack);
|
||||
return individual != null
|
||||
&& individual.getGenome() != null
|
||||
&& individual.hasEffect();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
IFlowerColor primaryColor = genome.getPrimaryColor();
|
||||
IFlowerColor secondColor = genome.getSecondaryColor();
|
||||
IFlowerColor stemColor = genome.getStemColor();
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
return individual != null && individual.hasEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
|
||||
IFlower individual = (IFlower) getIndividual(itemStack);
|
||||
if (individual == null) {
|
||||
list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
//Colors
|
||||
String primaryColor = genome.getPrimaryColor().getColorName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColorName();
|
||||
String stemColor = genome.getStemColor().getColorName();
|
||||
String colorInfo;
|
||||
if (!primaryColor.equals(secondaryColor)) {
|
||||
colorInfo = I18N.localise("item.botany.grammar.flower.secondary");
|
||||
} else {
|
||||
colorInfo = I18N.localise("item.botany.grammar.flower");
|
||||
}
|
||||
list.add(TextFormatting.YELLOW + colorInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
|
||||
if (individual.isAnalyzed()) {
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
individual.addTooltip(list);
|
||||
} else {
|
||||
list.add(TextFormatting.ITALIC + "<" + I18N.localise("for.gui.tooltip.tmi") + ">");
|
||||
}
|
||||
} else {
|
||||
list.add("<" + I18N.localise("for.gui.unknown") + ">");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IIndividual getIndividual(ItemStack itemstack) {
|
||||
return new Flower(itemstack.getTagCompound());
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
if (tagCompound == null) {
|
||||
return null;
|
||||
}
|
||||
return new Flower(tagCompound);
|
||||
}
|
||||
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(ItemStack itemstack) {
|
||||
IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
if (tree == null) {
|
||||
return (IAlleleFlowerSpecies) BotanyCore.getFlowerRoot().getDefaultTemplate()[EnumFlowerChromosome.SPECIES.ordinal()];
|
||||
}
|
||||
return tree.getGenome().getPrimary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return I18N.localise("botany.item.tooltip.unknown");
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
|
||||
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);
|
||||
if (individual != null) {
|
||||
return individual.getDisplayName() + (!tag.isEmpty() ? " " + I18N.localise("item.botany." + tag + ".name") : "");
|
||||
}
|
||||
return I18N.localise("botany.item.flowerCorrupted.name");
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
addCreativeItems(itemList, true);
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
addCreativeItems(items, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCreativeItems(List itemList, boolean hideSecrets) {
|
||||
for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) {
|
||||
public void addCreativeItems(NonNullList<ItemStack> itemList, boolean hideSecrets) {
|
||||
for (IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
|
||||
continue;
|
||||
}
|
||||
itemList.add(BotanyCore.speciesRoot.getMemberStack(individual.copy(), getStage().ordinal()));
|
||||
itemList.add(BotanyCore.getFlowerRoot().getMemberStack(individual.copy(), type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
|
||||
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
|
||||
if (flower == null || flower.getGenome() == null) {
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
if (renderPass == 0) {
|
||||
if (tintIndex == 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 boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 3;
|
||||
return (tintIndex == 1)
|
||||
? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
|
||||
: flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
|
||||
}
|
||||
|
||||
@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();
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (IFlowerType flowerType : (List<IFlowerType>) BlockFlower.FLOWER.getAllowedValues()) {
|
||||
flowerType.registerModels(item, manager, type);
|
||||
}
|
||||
|
||||
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);
|
||||
manager.registerItemModel(item, new BotanyMeshDefinition());
|
||||
}
|
||||
|
||||
@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;
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (type == EnumFlowerStage.POLLEN) {
|
||||
return pollinateFlower(world, pos, player, stack);
|
||||
}
|
||||
|
||||
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 (itemstack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, itemstack)) {
|
||||
return false;
|
||||
}
|
||||
if (y == 255 && blockFlower.getMaterial().isSolid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
return placeFlower(player, stack, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@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++;
|
||||
}
|
||||
private EnumActionResult pollinateFlower(World world, BlockPos pos, EntityPlayer player, ItemStack stack){
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
TileEntity target = world.getTileEntity(pos);
|
||||
if (!(target instanceof IPollinatable)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
return world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack);
|
||||
IPollinatable pollinatable = (IPollinatable) target;
|
||||
if (!pollinatable.canMateWith(flower)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
pollinatable.mateWith(flower);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
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)) {
|
||||
private EnumActionResult placeFlower(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = getMetadata(stack.getMetadata());
|
||||
IBlockState stateForPlacement = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, stateForPlacement)) {
|
||||
SoundType soundType = block.getSoundType(stateForPlacement, world, pos, player);
|
||||
world.playSound(player, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
if (!world.setBlockState(pos, newState, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == block) {
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == Botany.flower) {
|
||||
ItemBlock.setTileEntityNBT(world, player, pos, stack);
|
||||
Botany.flower.onBlockPlacedBy(world, pos, state, player, stack);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract EnumFlowerStage getStage();
|
||||
|
||||
public abstract String getTag();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class BotanyMeshDefinition implements ItemMeshDefinition {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
Preconditions.checkNotNull(flower);
|
||||
IAlleleFlowerSpecies flowerSpecies = flower.getGenome().getPrimary();
|
||||
IFlowerType flowerType = flowerSpecies.getType();
|
||||
return flowerSpecies.getFlowerModel(type, flower.hasFlowered());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,166 +1,126 @@
|
||||
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 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.util.IIcon;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemInsulatedTube extends Item {
|
||||
IIcon[] icons;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuit;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.circuits.SolderManager;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.core.item.ItemCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
public ItemInsulatedTube() {
|
||||
icons = new IIcon[3];
|
||||
setUnlocalizedName("insulatedTube");
|
||||
super("insulated_tube");
|
||||
setUnlocalizedName("botany.insulated_tube");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
private static Multimap<ICircuitLayout, ICircuit> getCircuits(ItemStack itemStack) {
|
||||
Multimap<ICircuitLayout, ICircuit> circuits = ArrayListMultimap.create();
|
||||
Collection<ICircuitLayout> allLayouts = ChipsetManager.circuitRegistry.getRegisteredLayouts().values();
|
||||
for (ICircuitLayout circuitLayout : allLayouts) {
|
||||
ICircuit circuit = SolderManager.getCircuit(circuitLayout, itemStack);
|
||||
if (circuit != null) {
|
||||
circuits.put(circuitLayout, circuit);
|
||||
}
|
||||
}
|
||||
return circuits;
|
||||
}
|
||||
|
||||
public static String getInsulate(ItemStack stack) {
|
||||
return EnumTubeInsulate.get(stack.getItemDamage()).getDisplayName();
|
||||
}
|
||||
|
||||
public static ItemStack getInsulateStack(ItemStack stack) {
|
||||
return Insulate.get(stack.getItemDamage()).getStack();
|
||||
return EnumTubeInsulate.get(stack.getItemDamage()).getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
for (EnumTubeMaterial mat : EnumTubeMaterial.values()) {
|
||||
for (EnumTubeInsulate ins : EnumTubeInsulate.values()) {
|
||||
items.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (EnumTubeMaterial mat : EnumTubeMaterial.values()) {
|
||||
for (EnumTubeInsulate ins : EnumTubeInsulate.values()) {
|
||||
manager.registerItemModel(item, mat.ordinal() + ins.ordinal() * 128);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
if (pass == 0) {
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
if (tintIndex == 0) {
|
||||
return 0xffffff;
|
||||
} else if (tintIndex == 1) {
|
||||
return EnumTubeMaterial.get(stack.getItemDamage()).getColor();
|
||||
}
|
||||
return (pass == 1) ?
|
||||
Material.get(stack.getItemDamage()).getColor() :
|
||||
Insulate.get(stack.getItemDamage()).getColor();
|
||||
return EnumTubeInsulate.get(stack.getItemDamage()).getColor();
|
||||
}
|
||||
|
||||
@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
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return Material.get(stack.getItemDamage()).getName() + " "
|
||||
+ I18N.localise("botany.tube.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass) {
|
||||
return icons[pass % 3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
enum Material {
|
||||
Copper(0xe3b78e, "cooper"),
|
||||
Tin(0xe1eef4, "tin"),
|
||||
Bronze(0xddc276, "bronze"),
|
||||
Iron(0xd8d8d8, "iron");
|
||||
|
||||
protected int color;
|
||||
protected String name;
|
||||
|
||||
Material(int color, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Material get(int i) {
|
||||
return values()[i % values().length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return I18N.localise("botany.tube." + name);
|
||||
}
|
||||
}
|
||||
|
||||
enum Insulate {
|
||||
Clay(0xa1aacc, "clay"),
|
||||
Cobble(0x7b7b7b, "cobblestone"),
|
||||
Sand(0xefeab5, "sand"),
|
||||
HardenedClay(0x935c43, "hardenedClay"),
|
||||
Stone(0x6d6d6d, "smoothStone"),
|
||||
Sandstone(0xc1b989, "sandstone");
|
||||
|
||||
protected int color;
|
||||
protected String name;
|
||||
|
||||
Insulate(int color, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Insulate get(int i) {
|
||||
return values()[i / 128 % values().length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return I18N.localise("botany.tube.insulate." + name);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
switch (this) {
|
||||
case Clay:
|
||||
return new ItemStack(Blocks.clay);
|
||||
|
||||
case Cobble:
|
||||
return new ItemStack(Blocks.cobblestone);
|
||||
|
||||
case HardenedClay:
|
||||
return new ItemStack(Blocks.hardened_clay);
|
||||
|
||||
case Sand:
|
||||
return new ItemStack(Blocks.sand);
|
||||
|
||||
case Sandstone:
|
||||
return new ItemStack(Blocks.sandstone);
|
||||
|
||||
case Stone:
|
||||
return new ItemStack(Blocks.stone);
|
||||
public void addInformation(ItemStack itemstack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
|
||||
super.addInformation(itemstack, worldIn, list, flagIn);
|
||||
Multimap<ICircuitLayout, ICircuit> circuits = getCircuits(itemstack);
|
||||
if (!circuits.isEmpty()) {
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
for (ICircuitLayout circuitLayout : circuits.keys()) {
|
||||
String circuitLayoutName = circuitLayout.getUsage();
|
||||
list.add(TextFormatting.WHITE.toString() + TextFormatting.UNDERLINE + circuitLayoutName);
|
||||
for (ICircuit circuit : circuits.get(circuitLayout)) {
|
||||
circuit.addTooltip(list);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list.add(TextFormatting.ITALIC + "<" + Translator.translateToLocal("for.gui.tooltip.tmi") + ">");
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
list.add("<" + Translator.translateToLocal("for.gui.noeffect") + ">");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
int meta = itemStack.getMetadata();
|
||||
return I18N.localise(
|
||||
"item.botany.insulated_tube.name",
|
||||
EnumTubeMaterial.get(meta).getDisplayName(),
|
||||
EnumTubeInsulate.get(meta).getDisplayName()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return I18N.localise("botany.item.pollen.tag.name");
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return I18N.localise("botany.item.germling.tag.name");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.properties.PropertyHelper;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
|
||||
public class PropertyFlower<I extends IFlowerType<I>> extends PropertyHelper<I> {
|
||||
public PropertyFlower(String name, Class<I> flowerTypeClass) {
|
||||
super(name, flowerTypeClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<I> getAllowedValues() {
|
||||
List<I> flowerTypes = new ArrayList<>();
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleFlowerSpecies) {
|
||||
IFlowerType flowerType = ((IAlleleFlowerSpecies) allele).getType();
|
||||
if (!flowerTypes.contains(flowerType)) {
|
||||
flowerTypes.add((I) flowerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return flowerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name for the given value.
|
||||
*/
|
||||
@Override
|
||||
public String getName(IFlowerType value) {
|
||||
return value.getName().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<I> parseValue(String value) {
|
||||
IAllele allele = AlleleManager.alleleRegistry.getAllele(value);
|
||||
if (IAlleleFlowerSpecies.class.isInstance(allele)) {
|
||||
IAlleleFlowerSpecies alleleValue = IAlleleFlowerSpecies.class.cast(allele);
|
||||
return Optional.of((I) alleleValue.getType());
|
||||
}
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
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;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return RendererBotany.renderID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class StateMapperFlower extends StateMapperBase {
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
Map<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
IFlowerType flowerType = (IFlowerType) state.getValue(BlockFlower.FLOWER);
|
||||
if (flowerType.getSections() < 2) {
|
||||
properties.remove(BlockFlower.SECTION);
|
||||
} else if (flowerType.getSections() <= state.getValue(BlockFlower.SECTION)) {
|
||||
properties.put(BlockFlower.SECTION, flowerType.getSections() - 1);
|
||||
}
|
||||
|
||||
if (state.getValue(BlockFlower.SEED)) {
|
||||
properties.remove(BlockFlower.SECTION);
|
||||
properties.remove(BlockFlower.FLOWER);
|
||||
properties.remove(BlockFlower.FLOWERED);
|
||||
} else {
|
||||
properties.remove(BlockFlower.SEED);
|
||||
}
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,35 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
@@ -8,46 +38,27 @@ import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.gardening.BlockPlant;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.botany.gardening.PlantType;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.botany.genetics.Flower;
|
||||
import binnie.botany.network.MessageFlowerUpdate;
|
||||
import binnie.core.BinnieCore;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
import forestry.lepidopterology.entities.EntityButterfly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class TileEntityFlower extends TileEntity implements IPollinatable, IButterflyNursery {
|
||||
protected IFlower flower;
|
||||
protected GameProfile owner;
|
||||
protected int section;
|
||||
protected RenderInfo renderInfo;
|
||||
protected IButterfly caterpillar;
|
||||
protected int matureTime;
|
||||
@Nullable
|
||||
IFlower flower;
|
||||
@Nullable
|
||||
GameProfile owner;
|
||||
int section;
|
||||
@Nullable
|
||||
RenderInfo renderInfo;
|
||||
@Nullable
|
||||
IButterfly caterpillar;
|
||||
int matureTime;
|
||||
|
||||
public TileEntityFlower() {
|
||||
flower = null;
|
||||
@@ -57,49 +68,61 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
flower = new Flower(nbttagcompound);
|
||||
section = nbttagcompound.getByte("section");
|
||||
if (flower.getAge() == 0) {
|
||||
flower.setFlowered(false);
|
||||
public void readFromNBT(NBTTagCompound nbtCompound) {
|
||||
if (nbtCompound.hasKey("Flower")) {
|
||||
flower = new Flower(nbtCompound.getCompoundTag("Flower"));
|
||||
if (flower.getAge() == 0) {
|
||||
flower.setFlowered(false);
|
||||
}
|
||||
}
|
||||
|
||||
owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
||||
if (nbttagcompound.hasKey("CATER") && BinnieCore.isLepidopteryActive()) {
|
||||
matureTime = nbttagcompound.getInteger("caterTime");
|
||||
caterpillar = Binnie.Genetics.getButterflyRoot().getMember(nbttagcompound.getCompoundTag("cater"));
|
||||
if (nbtCompound.hasKey("section")) {
|
||||
section = nbtCompound.getByte("section");
|
||||
}
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (nbtCompound.hasKey("owner")) {
|
||||
owner = NBTUtil.readGameProfileFromNBT(nbtCompound.getCompoundTag("owner"));
|
||||
}
|
||||
|
||||
if (nbtCompound.hasKey("CATER") && BinnieCore.isLepidopteryActive()) {
|
||||
matureTime = nbtCompound.getInteger("caterTime");
|
||||
caterpillar = Binnie.GENETICS.getButterflyRoot().getMember(nbtCompound.getCompoundTag("cater"));
|
||||
}
|
||||
|
||||
readRenderInfo(nbtCompound);
|
||||
super.readFromNBT(nbtCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtCompound) {
|
||||
if (flower != null) {
|
||||
flower.writeToNBT(nbttagcompound);
|
||||
nbtCompound.setTag("Flower", flower.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if (owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a(nbt, owner);
|
||||
nbttagcompound.setTag("owner", nbt);
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
nbtCompound.setTag("owner", nbt);
|
||||
}
|
||||
|
||||
if (caterpillar != null) {
|
||||
nbttagcompound.setInteger("caterTime", matureTime);
|
||||
nbtCompound.setInteger("caterTime", matureTime);
|
||||
NBTTagCompound subcompound = new NBTTagCompound();
|
||||
caterpillar.writeToNBT(subcompound);
|
||||
nbttagcompound.setTag("cater", subcompound);
|
||||
nbtCompound.setTag("cater", subcompound);
|
||||
}
|
||||
nbttagcompound.setByte("section", (byte) getSection());
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbtCompound.setByte("section", (byte) getSection());
|
||||
return super.writeToNBT(nbtCompound);
|
||||
}
|
||||
|
||||
public void create(ItemStack stack, GameProfile owner) {
|
||||
create(BotanyCore.getFlowerRoot().getMember(stack), owner);
|
||||
public void create(ItemStack stack, @Nullable GameProfile owner) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
create(flower, owner);
|
||||
}
|
||||
|
||||
public void create(IFlower stack, GameProfile owner) {
|
||||
flower = stack;
|
||||
public void create(IFlower flower, @Nullable GameProfile owner) {
|
||||
this.flower = flower;
|
||||
if (flower.getAge() == 0) {
|
||||
flower.setFlowered(false);
|
||||
}
|
||||
@@ -109,11 +132,12 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<EnumPlantType> getPlantType() {
|
||||
return EnumSet.of(EnumPlantType.Plains);
|
||||
public EnumPlantType getPlantType() {
|
||||
return EnumPlantType.Plains;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IIndividual getPollen() {
|
||||
return getFlower();
|
||||
}
|
||||
@@ -121,11 +145,11 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
@Override
|
||||
public boolean canMateWith(IIndividual individual) {
|
||||
return isBreeding()
|
||||
&& individual instanceof IFlower
|
||||
&& getFlower() != null
|
||||
&& getFlower().getMate() == null
|
||||
&& getFlower().hasFlowered()
|
||||
&& !getFlower().isGeneticEqual(individual);
|
||||
&& individual instanceof IFlower
|
||||
&& getFlower() != null
|
||||
&& getFlower().getMate() == null
|
||||
&& getFlower().hasFlowered()
|
||||
&& !getFlower().isGeneticEqual(individual);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,18 +160,19 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary();
|
||||
IAlleleFlowerSpecies primary2 = getFlower().getGenome().getPrimary();
|
||||
if (primary == primary2 || worldObj.rand.nextInt(4) == 0) {
|
||||
if (primary == primary2 || world.rand.nextInt(4) == 0) {
|
||||
getFlower().mate((IFlower) individual);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IFlower getFlower() {
|
||||
if (getSection() <= 0) {
|
||||
return flower;
|
||||
}
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord - getSection(), zCoord);
|
||||
TileEntity tile = world.getTileEntity(pos.down(getSection()));
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
return ((TileEntityFlower) tile).getFlower();
|
||||
}
|
||||
@@ -155,38 +180,104 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public boolean isBreeding() {
|
||||
Block roots = getWorldObj().getBlock(xCoord, yCoord - 1, zCoord);
|
||||
return Gardening.isSoil(roots);
|
||||
Block roots = getWorld().getBlockState(getPos().down()).getBlock();
|
||||
return BotanyCore.getGardening().isSoil(roots);
|
||||
}
|
||||
|
||||
public void randomUpdate(Random rand) {
|
||||
if (worldObj.getBlock(xCoord, yCoord, zCoord) != Botany.flower) {
|
||||
if (world.getBlockState(pos).getBlock() != Botany.flower) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (getSection() > 0 || flower == null) {
|
||||
if (getSection() > 0) {
|
||||
return;
|
||||
}
|
||||
if (flower == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flower.getGenome() == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (!isBreeding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float light = worldObj.getBlockLightValue(xCoord, yCoord, zCoord);
|
||||
if (light < 6.0f) {
|
||||
for (int dx = -2; dx <= 2; ++dx) {
|
||||
for (int dy = -2; dy <= 2; ++dy) {
|
||||
light -= (worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) ? 0.0f : 0.5f);
|
||||
if(updateState(rand)){
|
||||
return;
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
EnumSoilType soil = gardening.getSoilType(world, pos.down());
|
||||
float chanceDispersal = 0.8f;
|
||||
chanceDispersal += 0.2f * flower.getGenome().getFertility();
|
||||
chanceDispersal *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chancePollinate = 1.0f;
|
||||
chancePollinate += 0.25f * flower.getGenome().getFertility();
|
||||
chancePollinate *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chanceSelfPollinate = 0.2f * chancePollinate;
|
||||
plantOffspring(rand, chanceDispersal);
|
||||
|
||||
mateFlower(rand, chancePollinate, chanceSelfPollinate);
|
||||
spawnButterflies();
|
||||
matureCaterpillar();
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
}
|
||||
|
||||
private void mateFlower(Random rand, float chancePollinate, float chanceSelfPollinate){
|
||||
if (world.rand.nextFloat() < chancePollinate && flower.hasFlowered() && !flower.isWilted()) {
|
||||
for (int a2 = 0; a2 < 4; ++a2) {
|
||||
int dx3;
|
||||
int dz2;
|
||||
for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2));
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(getFlower())) {
|
||||
((IPollinatable) tile).mateWith(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean canTolerate = Gardening.canTolerate(getFlower(), worldObj, xCoord, yCoord, zCoord);
|
||||
EnumSoilType soil = Gardening.getSoilType(worldObj, xCoord, yCoord, zCoord);
|
||||
if (world.rand.nextFloat() < chanceSelfPollinate && flower.hasFlowered() && flower.getMate() == null) {
|
||||
mateWith(getFlower());
|
||||
}
|
||||
}
|
||||
|
||||
private void plantOffspring(Random rand, float chanceDispersal){
|
||||
if (world.rand.nextFloat() < chanceDispersal && flower.hasFlowered() && !flower.isWilted()) {
|
||||
IFlowerGenome mate = flower.getMate();
|
||||
if (mate != null) {
|
||||
boolean dispersed = false;
|
||||
for (int a = 0; a < 5 && !dispersed; ++a) {
|
||||
int dx2;
|
||||
int dz;
|
||||
for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) {
|
||||
}
|
||||
|
||||
Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock();
|
||||
if (world.isAirBlock(pos.add(dx2, 0, dz)) && BotanyCore.getGardening().isSoil(b2)) {
|
||||
IFlower offspring = flower.getOffspring(world, pos);
|
||||
if (offspring != null) {
|
||||
BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, getOwner());
|
||||
flower.removeMate();
|
||||
dispersed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateState(Random rand){
|
||||
float light = world.getLight(pos);
|
||||
if (light < 6.0f) {
|
||||
for (int offsetX = -2; offsetX <= 2; ++offsetX) {
|
||||
for (int offsetY = -2; offsetY <= 2; ++offsetY) {
|
||||
light -= (world.canBlockSeeSky(pos.add(offsetX, 0, offsetY)) ? 0.0f : 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
boolean canTolerate = gardening.canTolerate(getFlower(), world, pos);
|
||||
if (rand.nextFloat() < getFlower().getGenome().getAgeChance()) {
|
||||
if (flower.getAge() < 1) {
|
||||
if (canTolerate && light > 6.0f) {
|
||||
@@ -200,14 +291,15 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
if (canTolerate && flower.getAge() > 1 && !flower.isWilted() && light > 6.0f) {
|
||||
flower.setFlowered(true);
|
||||
}
|
||||
|
||||
if (!canTolerate && flower.isWilted() && rand.nextInt(2 + Math.max(flower.getAge(), 2)) == 0) {
|
||||
kill();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (light < 2.0f && flower.isWilted()) {
|
||||
kill();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!canTolerate || light < 1.0f) {
|
||||
@@ -216,85 +308,71 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
flower.setWilted(false);
|
||||
}
|
||||
|
||||
float chanceDispersal = 0.8f;
|
||||
chanceDispersal += 0.2f * flower.getGenome().getFertility();
|
||||
chanceDispersal *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chancePollinate = 1.0f;
|
||||
chancePollinate += 0.25f * flower.getGenome().getFertility();
|
||||
chancePollinate *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chanceSelfPollinate = 0.2f * chancePollinate;
|
||||
|
||||
if (worldObj.rand.nextFloat() < chanceDispersal && flower.hasFlowered() && !flower.isWilted()) {
|
||||
IFlowerGenome mate = flower.getMate();
|
||||
if (mate != null) {
|
||||
boolean dispersed = false;
|
||||
for (int a = 0; a < 5 && !dispersed; ++a) {
|
||||
int dx2 = 0;
|
||||
int dz = 0;
|
||||
while (dx2 == 0 && dz == 0) {
|
||||
dx2 = rand.nextInt(3) - 1;
|
||||
dz = rand.nextInt(3) - 1;
|
||||
}
|
||||
|
||||
Block b = getWorldObj().getBlock(xCoord + dx2, yCoord, zCoord + dz);
|
||||
Block b2 = getWorldObj().getBlock(xCoord + dx2, yCoord - 1, zCoord + dz);
|
||||
if (b == Blocks.air && Gardening.isSoil(b2)) {
|
||||
IFlower offspring = flower.getOffspring(getWorldObj());
|
||||
if (offspring != null) {
|
||||
Gardening.plant(getWorldObj(), xCoord + dx2, yCoord, zCoord + dz, offspring, getOwner());
|
||||
flower.removeMate();
|
||||
dispersed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.rand.nextFloat() < chancePollinate && flower.hasFlowered() && !flower.isWilted()) {
|
||||
for (int a2 = 0; a2 < 4; ++a2) {
|
||||
int dx3 = 0;
|
||||
int dz2 = 0;
|
||||
while (dx3 == 0 && dz2 == 0) {
|
||||
dx3 = rand.nextInt(5) - 2;
|
||||
dz2 = rand.nextInt(5) - 2;
|
||||
}
|
||||
|
||||
TileEntity tile = getWorldObj().getTileEntity(xCoord + dx3, yCoord, zCoord + dz2);
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(getFlower())) {
|
||||
((IPollinatable) tile).mateWith(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.rand.nextFloat() < chanceSelfPollinate && flower.hasFlowered() && flower.getMate() == null) {
|
||||
mateWith(getFlower());
|
||||
}
|
||||
spawnButterflies();
|
||||
matureCaterpillar();
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void doFlowerAge() {
|
||||
getFlower().age();
|
||||
if (getFlower().getAge() != 1) {
|
||||
return;
|
||||
if (getFlower().getAge() == 1) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
flowerRoot.onGrowFromSeed(world, pos);
|
||||
if (getOwner() != null && getFlower() != null) {
|
||||
flowerRoot.getBreedingTracker(world, getOwner()).registerBirth(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gardening.onGrowFromSeed(worldObj, xCoord, yCoord, zCoord);
|
||||
if (getOwner() != null && getFlower() != null) {
|
||||
BotanyCore.getFlowerRoot().getBreedingTracker(getWorldObj(), getOwner()).registerBirth(getFlower());
|
||||
private NBTTagCompound writeRenderInfo(NBTTagCompound tag) {
|
||||
if (renderInfo != null) {
|
||||
NBTTagCompound nbtRenderInfo = new NBTTagCompound();
|
||||
nbtRenderInfo.setByte("primary", (byte) renderInfo.primary.getID());
|
||||
nbtRenderInfo.setByte("secondary", (byte) renderInfo.secondary.getID());
|
||||
nbtRenderInfo.setByte("stem", (byte) renderInfo.stem.getID());
|
||||
nbtRenderInfo.setByte("type", (byte) renderInfo.type.ordinal());
|
||||
nbtRenderInfo.setByte("age", renderInfo.age);
|
||||
nbtRenderInfo.setByte("section", renderInfo.section);
|
||||
nbtRenderInfo.setBoolean("wilted", renderInfo.wilted);
|
||||
nbtRenderInfo.setBoolean("flowered", renderInfo.flowered);
|
||||
tag.setTag("renderinfo", nbtRenderInfo);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
private void readRenderInfo(NBTTagCompound tag) {
|
||||
if (tag.hasKey("renderinfo")) {
|
||||
NBTTagCompound infotag = tag.getCompoundTag("renderinfo");
|
||||
RenderInfo info = new RenderInfo();
|
||||
info.primary = EnumFlowerColor.values()[infotag.getByte("primary")].getFlowerColorAllele();
|
||||
info.secondary = EnumFlowerColor.values()[infotag.getByte("secondary")].getFlowerColorAllele();
|
||||
info.stem = EnumFlowerColor.values()[infotag.getByte("stem")].getFlowerColorAllele();
|
||||
info.type = EnumFlowerType.values()[infotag.getByte("type")];
|
||||
info.age = infotag.getByte("age");
|
||||
info.section = infotag.getByte("section");
|
||||
info.wilted = infotag.getBoolean("wilted");
|
||||
info.flowered = infotag.getBoolean("flowered");
|
||||
setRender(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
if (renderInfo == null && getFlower() != null && getFlower().getGenome() != null) {
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
// TODO client only call?
|
||||
readRenderInfo(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
updateRender(true);
|
||||
return writeRenderInfo(super.getUpdateTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
if (renderInfo == null && getFlower() != null) {
|
||||
renderInfo = new RenderInfo(getFlower(), this);
|
||||
}
|
||||
return (renderInfo != null) ?
|
||||
Botany.instance.getNetworkWrapper().getPacketFrom(new MessageFlowerUpdate(xCoord, yCoord, zCoord, renderInfo).getMessage()) :
|
||||
null;
|
||||
return (renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null;
|
||||
}
|
||||
|
||||
public void updateRender(boolean update) {
|
||||
@@ -305,7 +383,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity above = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) above).updateRender(true);
|
||||
}
|
||||
@@ -317,26 +395,25 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
public void setSection(int i) {
|
||||
section = i;
|
||||
if (BinnieCore.proxy.isSimulating(worldObj)) {
|
||||
if (BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
updateRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
IFlower flower = getFlower();
|
||||
if (flower == null) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
int stage = (flower.getAge() == 0) ? EnumFlowerStage.SEED.ordinal() : EnumFlowerStage.FLOWER.ordinal();
|
||||
return Binnie.Genetics.getFlowerRoot().getMemberStack(getFlower(), stage);
|
||||
return Binnie.GENETICS.getFlowerRoot().getMemberStack(flower, EnumFlowerStage.getStage(flower));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TileEntityFlower getRoot() {
|
||||
if (getSection() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord - getSection(), zCoord);
|
||||
TileEntity tile = world.getTileEntity(pos.down(getSection()));
|
||||
return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null;
|
||||
}
|
||||
|
||||
@@ -352,15 +429,14 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
Random rand = new Random();
|
||||
IFlower cutting = (IFlower) getFlower().copy();
|
||||
cutting.setAge(0);
|
||||
ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED.ordinal());
|
||||
ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
|
||||
float f = 0.7f;
|
||||
double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
EntityItem entityitem = new EntityItem(worldObj, xCoord + d, yCoord + d2, zCoord + d3, cuttingStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
worldObj.spawnEntityInWorld(entityitem);
|
||||
|
||||
double xPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double yPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double zPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
EntityItem entityItem = new EntityItem(world, pos.getX() + xPos, pos.getY() + yPos, pos.getZ() + zPos, cuttingStack);
|
||||
entityItem.setPickupDelay(10);
|
||||
world.spawnEntity(entityItem);
|
||||
for (int maxAge = getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
|
||||
if (rand.nextBoolean()) {
|
||||
getFlower().age();
|
||||
@@ -376,53 +452,58 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return getRoot().checkIfDead(wasCut);
|
||||
}
|
||||
|
||||
EnumSoilType soil = Gardening.getSoilType(worldObj, xCoord, yCoord, zCoord);
|
||||
EnumSoilType soil = BotanyCore.getGardening().getSoilType(world, pos);
|
||||
int maxAge = (int) (flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
|
||||
if (flower.getAge() <= maxAge) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wasCut && flower.getMate() != null) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
IFlower offspring = flower.getOffspring(getWorldObj());
|
||||
TileEntity above = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
if (above instanceof TileEntityFlower) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
|
||||
if (flower.getAge() > maxAge) {
|
||||
if (!wasCut && flower.getMate() != null) {
|
||||
world.setBlockToAir(pos);
|
||||
IFlower offspring = flower.getOffspring(world, pos.down());
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
world.setBlockToAir(pos.up());
|
||||
}
|
||||
BotanyCore.getFlowerRoot().plant(world, pos, offspring, getOwner());
|
||||
} else {
|
||||
kill();
|
||||
}
|
||||
Gardening.plant(worldObj, xCoord, yCoord, zCoord, offspring, getOwner());
|
||||
} else {
|
||||
kill();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
if (flower.getAge() > 0) {
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, Botany.plant, BlockPlant.Type.DeadFlower.ordinal(), 2);
|
||||
world.setBlockState(pos, Botany.gardening().plant.getStateFromMeta(PlantType.DEAD_FLOWER.ordinal()), 2);
|
||||
} else {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
for (int i = 1; worldObj.getTileEntity(xCoord, yCoord + i, zCoord) instanceof TileEntityFlower; ++i) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord + i, zCoord);
|
||||
for (int i = 1; world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
|
||||
world.setBlockToAir(pos.up(i));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBonemeal() {
|
||||
if (getFlower() == null || !isBreeding() || getFlower().isWilted()) {
|
||||
if (getFlower() == null) {
|
||||
return false;
|
||||
}
|
||||
if (!isBreeding()) {
|
||||
return false;
|
||||
}
|
||||
if (getFlower().isWilted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
doFlowerAge();
|
||||
//this.doFlowerAge();
|
||||
if (getFlower().getAge() > 1 && !getFlower().hasFlowered()) {
|
||||
getFlower().setFlowered(true);
|
||||
}
|
||||
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameProfile getOwner() {
|
||||
return owner;
|
||||
}
|
||||
@@ -432,73 +513,88 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public void spawnButterflies() {
|
||||
if (!BinnieCore.isLepidopteryActive()) {
|
||||
/*if (!BinnieCore.isLepidopteryActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = xCoord;
|
||||
int y = yCoord;
|
||||
int z = zCoord;
|
||||
World world = worldObj;
|
||||
if (getCaterpillar() != null) {
|
||||
final int x = this.xCoord;
|
||||
final int y = this.yCoord;
|
||||
final int z = this.zCoord;
|
||||
final World world = this.worldObj;
|
||||
if (this.getCaterpillar() != null) {
|
||||
return;
|
||||
}
|
||||
if (world.rand.nextFloat() >= getFlower().getGenome().getSappiness()) {
|
||||
if (world.rand.nextFloat() >= this.getFlower().getGenome().getSappiness()) {
|
||||
return;
|
||||
}
|
||||
if (worldObj.rand.nextFloat() >= 0.2f) {
|
||||
if (this.worldObj.rand.nextFloat() >= 0.2f) {
|
||||
return;
|
||||
}
|
||||
|
||||
IButterfly spawn = Binnie.Genetics.getButterflyRoot().getIndividualTemplates().get(worldObj.rand.nextInt(Binnie.Genetics.getButterflyRoot().getIndividualTemplates().size()));
|
||||
if (worldObj.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f) {
|
||||
final IButterfly spawn = Binnie.Genetics.getButterflyRoot().getIndividualTemplates().get(this.worldObj.rand.nextInt(Binnie.Genetics.getButterflyRoot().getIndividualTemplates().size()));
|
||||
if (this.worldObj.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f) {
|
||||
return;
|
||||
}
|
||||
if (worldObj.countEntities(EntityButterfly.class) > 100) {
|
||||
if (this.worldObj.countEntities(EntityButterfly.class) > 100) {
|
||||
return;
|
||||
}
|
||||
if (!spawn.canSpawn(worldObj, x, y, z)) {
|
||||
if (!spawn.canSpawn(this.worldObj, x, y, z)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.isAirBlock(x, y + 1, z)) {
|
||||
attemptButterflySpawn(world, spawn, x, y + 1, z);
|
||||
} else if (world.isAirBlock(x - 1, y, z)) {
|
||||
attemptButterflySpawn(world, spawn, x - 1, y, z);
|
||||
} else if (world.isAirBlock(x + 1, y, z)) {
|
||||
attemptButterflySpawn(world, spawn, x + 1, y, z);
|
||||
} else if (world.isAirBlock(x, y, z - 1)) {
|
||||
attemptButterflySpawn(world, spawn, x, y, z - 1);
|
||||
} else if (world.isAirBlock(x, y, z + 1)) {
|
||||
attemptButterflySpawn(world, spawn, x, y, z + 1);
|
||||
this.attemptButterflySpawn(world, spawn, x, y + 1, z);
|
||||
}
|
||||
else if (world.isAirBlock(x - 1, y, z)) {
|
||||
this.attemptButterflySpawn(world, spawn, x - 1, y, z);
|
||||
}
|
||||
else if (world.isAirBlock(x + 1, y, z)) {
|
||||
this.attemptButterflySpawn(world, spawn, x + 1, y, z);
|
||||
}
|
||||
else if (world.isAirBlock(x, y, z - 1)) {
|
||||
this.attemptButterflySpawn(world, spawn, x, y, z - 1);
|
||||
}
|
||||
else if (world.isAirBlock(x, y, z + 1)) {
|
||||
this.attemptButterflySpawn(world, spawn, x, y, z + 1);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) {
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
Binnie.Genetics.getButterflyRoot().spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.10000000149011612, z);
|
||||
Binnie.GENETICS.getButterflyRoot().spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.10000000149011612, z);
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return getWorldObj();
|
||||
}
|
||||
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(worldObj.getBiomeGenForCoords(xCoord, zCoord).temperature);
|
||||
}
|
||||
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(worldObj.getBiomeGenForCoords(xCoord, zCoord).rainfall);
|
||||
public GameProfile getOwnerName() {
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(world.getBiome(getPos()).getTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(world.getBiome(getPos()).getRainfall());
|
||||
}
|
||||
|
||||
public void setErrorState(int state) {
|
||||
}
|
||||
|
||||
public int getErrorOrdinal() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IButterfly getCaterpillar() {
|
||||
return caterpillar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaterpillar(IButterfly butterfly) {
|
||||
public void setCaterpillar(@Nullable IButterfly butterfly) {
|
||||
caterpillar = butterfly;
|
||||
matureTime = 0;
|
||||
}
|
||||
@@ -514,31 +610,40 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
private void matureCaterpillar() {
|
||||
if (getCaterpillar() == null) {
|
||||
//TODO Spawn the caterpillar in a cocon on the next Tree or other thing
|
||||
/*if (this.getCaterpillar() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
matureTime++;
|
||||
if (matureTime >= caterpillar.getGenome().getLifespan() / (caterpillar.getGenome().getFertility() * 2) && caterpillar.canTakeFlight(worldObj, xCoord, yCoord, zCoord)) {
|
||||
if (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord)) {
|
||||
attemptButterflySpawn(worldObj, caterpillar, xCoord, yCoord + 1, zCoord);
|
||||
} else if (worldObj.isAirBlock(xCoord - 1, yCoord, zCoord)) {
|
||||
attemptButterflySpawn(worldObj, caterpillar, xCoord - 1, yCoord, zCoord);
|
||||
} else if (worldObj.isAirBlock(xCoord + 1, yCoord, zCoord)) {
|
||||
attemptButterflySpawn(worldObj, caterpillar, xCoord + 1, yCoord, zCoord);
|
||||
} else if (worldObj.isAirBlock(xCoord, yCoord, zCoord - 1)) {
|
||||
attemptButterflySpawn(worldObj, caterpillar, xCoord, yCoord, zCoord - 1);
|
||||
} else if (worldObj.isAirBlock(xCoord, yCoord, zCoord + 1)) {
|
||||
attemptButterflySpawn(worldObj, caterpillar, xCoord, yCoord, zCoord + 1);
|
||||
++this.matureTime;
|
||||
if (this.matureTime >= this.caterpillar.getGenome().getLifespan() / (this.caterpillar.getGenome().getFertility() * 2) && this.caterpillar.canTakeFlight(this.worldObj, this.xCoord, this.yCoord, this.zCoord)) {
|
||||
if (this.worldObj.isAirBlock(this.xCoord, this.yCoord + 1, this.zCoord)) {
|
||||
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord + 1, this.zCoord);
|
||||
}
|
||||
setCaterpillar(null);
|
||||
}
|
||||
else if (this.worldObj.isAirBlock(this.xCoord - 1, this.yCoord, this.zCoord)) {
|
||||
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord - 1, this.yCoord, this.zCoord);
|
||||
}
|
||||
else if (this.worldObj.isAirBlock(this.xCoord + 1, this.yCoord, this.zCoord)) {
|
||||
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord + 1, this.yCoord, this.zCoord);
|
||||
}
|
||||
else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord - 1)) {
|
||||
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord - 1);
|
||||
}
|
||||
else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord + 1)) {
|
||||
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord + 1);
|
||||
}
|
||||
this.setCaterpillar(null);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void setRender(RenderInfo render) {
|
||||
renderInfo = render;
|
||||
section = renderInfo.section;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if (!world.isRemote) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, blockState, blockState, 0);
|
||||
} else {
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
@@ -557,45 +662,66 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return renderInfo == null || renderInfo.flowered;
|
||||
}
|
||||
|
||||
public int getPrimaryColor() {
|
||||
return (renderInfo == null) ?
|
||||
EnumFlowerColor.RED.getColor(false) :
|
||||
renderInfo.primary.getColor(isWilted());
|
||||
public int getPrimaryColour() {
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.primary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getSecondaryColor() {
|
||||
return (renderInfo == null) ?
|
||||
EnumFlowerColor.RED.getColor(false) :
|
||||
renderInfo.secondary.getColor(isWilted());
|
||||
public int getSecondaryColour() {
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.secondary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getStemColour() {
|
||||
return (renderInfo == null) ?
|
||||
EnumFlowerColor.GREEN.getColor(false) :
|
||||
renderInfo.stem.getColor(isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.stem.getColor(isWilted());
|
||||
}
|
||||
|
||||
public IFlowerType getType() {
|
||||
return (renderInfo == null) ?
|
||||
EnumFlowerType.POPPY :
|
||||
renderInfo.type;
|
||||
}
|
||||
|
||||
public BiomeGenBase getBiome() {
|
||||
return getWorld().getBiomeGenForCoords(xCoord, zCoord);
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerType.Poppy
|
||||
: renderInfo.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(xCoord, yCoord, zCoord);
|
||||
public Biome getBiome() {
|
||||
return getWorld().getBiome(getPos());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IErrorState getErrorState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setErrorState(IErrorState state) {
|
||||
}
|
||||
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCoordinates() {
|
||||
return getPos();
|
||||
}
|
||||
|
||||
// TODO ??
|
||||
@Override
|
||||
public boolean isPollinated() {
|
||||
return isBreeding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorldObj() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public static class RenderInfo {
|
||||
public IFlowerColor primary;
|
||||
public IFlowerColor secondary;
|
||||
@@ -624,13 +750,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof RenderInfo) {
|
||||
RenderInfo o = (RenderInfo) obj;
|
||||
return o.age == age
|
||||
&& o.wilted == wilted
|
||||
&& o.flowered == flowered
|
||||
&& o.primary == primary
|
||||
&& o.secondary == secondary
|
||||
&& o.stem == stem
|
||||
&& o.type == type;
|
||||
return o.age == age && o.wilted == wilted && o.flowered == flowered && o.primary == primary && o.secondary == secondary && o.stem == stem && o.type == type;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.flower;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,156 +1,153 @@
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
|
||||
public class BlockPlant extends BlockBush {
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
public static final PropertyEnum<PlantType> PLANT_TYPE = PropertyEnum.create("plant_type", PlantType.class);
|
||||
|
||||
public BlockPlant() {
|
||||
setBlockName("plant");
|
||||
setRegistryName("plant");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setTickRandomly(true);
|
||||
setSoundType(SoundType.PLANT);
|
||||
}
|
||||
|
||||
public static boolean isWeed(IBlockAccess world, int x, int y, int z) {
|
||||
if (!(world.getBlock(x, y, z) instanceof BlockPlant)) {
|
||||
public static boolean isWeed(IBlockAccess world, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (!(blockState.getBlock() instanceof BlockPlant)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Type type = Type.get(world.getBlockMetadata(x, y, z));
|
||||
return type == Type.Weeds
|
||||
|| type == Type.WeedsLong
|
||||
|| type == Type.WeedsVeryLong;
|
||||
PlantType type = blockState.getValue(PLANT_TYPE);
|
||||
return type.isWeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
int index = 0;
|
||||
for (PlantType type : PlantType.values()) {
|
||||
manager.registerItemModel(item, index, type.getName());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, PLANT_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(PLANT_TYPE).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(PLANT_TYPE, PlantType.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (Type t : Type.values()) {
|
||||
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
|
||||
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
|
||||
return super.canPlaceBlockAt(worldIn, pos) || BotanyCore.getGardening().isSoil(worldIn.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs p_149666_2_, NonNullList<ItemStack> subBlocks) {
|
||||
for (PlantType type : PlantType.values()) {
|
||||
subBlocks.add(type.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlaceBlockOn(Block block) {
|
||||
return super.canPlaceBlockOn(block) || Gardening.isSoil(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return Type.values()[meta % Type.values().length].icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (Type type : Type.values()) {
|
||||
list.add(type.get());
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
PlantType type = state.getValue(PLANT_TYPE);
|
||||
if (rand.nextInt(4) == 0) {
|
||||
if (type == PlantType.WEEDS) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2);
|
||||
} else if (type == PlantType.WEEDS_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_VERY_LONG), 2);
|
||||
} else if (type == PlantType.DEAD_FLOWER) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.DECAYING_FLOWER), 2);
|
||||
} else if (type == PlantType.DECAYING_FLOWER) {
|
||||
world.setBlockToAir(pos);
|
||||
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);
|
||||
if (rand.nextInt(6) == 0) {
|
||||
if (type == PlantType.WEEDS) {
|
||||
world.setBlockToAir(pos);
|
||||
} else if (type == PlantType.WEEDS_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS), 2);
|
||||
} else if (type == PlantType.WEEDS_VERY_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Block below = world.getBlock(x, y - 1, z);
|
||||
if (!Gardening.isSoil(below)) {
|
||||
Block below = world.getBlockState(pos.down()).getBlock();
|
||||
if (!BotanyCore.getGardening().isSoil(below)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBlockSoil soil = (IBlockSoil) below;
|
||||
if (random.nextInt(3) != 0) {
|
||||
if (rand.nextInt(3) != 0) {
|
||||
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);
|
||||
if (type.isWeed()) {
|
||||
if (!soil.degrade(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.degrade(world, pos.down(), 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);
|
||||
} else if (type == PlantType.DECAYING_FLOWER && !soil.fertilise(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.fertilise(world, pos.down(), EnumSoilType.FLOWERBED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
Weeds("weeds"),
|
||||
WeedsLong("longWeeds"),
|
||||
WeedsVeryLong("veryLongWeeds"),
|
||||
DeadFlower("deadFlower"),
|
||||
DecayingFlower("decayingFlower");
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
protected String name;
|
||||
|
||||
Type(String name) {
|
||||
this.name = 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);
|
||||
}
|
||||
@Override
|
||||
public EnumOffsetType getOffsetType() {
|
||||
return EnumOffsetType.XZ;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +1,141 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSoil extends Block implements IBlockSoil {
|
||||
protected boolean weedKilled;
|
||||
protected IIcon[] iconsTop;
|
||||
protected IIcon[] iconsSide;
|
||||
protected IIcon[] iconsNoWeed;
|
||||
protected EnumSoilType type;
|
||||
public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
public static final PropertyEnum<EnumMoisture> MOISTURE = PropertyEnum.create("moisture", EnumMoisture.class);
|
||||
public static final PropertyEnum<EnumAcidity> ACIDITY = PropertyEnum.create("acidity", EnumAcidity.class);
|
||||
public static final AxisAlignedBB SOIL_BLOCK_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.9375D, 1.0D);
|
||||
private final boolean weedKilled;
|
||||
private final EnumSoilType type;
|
||||
|
||||
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
|
||||
super(Material.ground);
|
||||
super(Material.GROUND);
|
||||
this.type = type;
|
||||
this.weedKilled = weedKilled;
|
||||
iconsTop = new IIcon[9];
|
||||
iconsSide = new IIcon[9];
|
||||
iconsNoWeed = new IIcon[9];
|
||||
setUnlocalizedName("botany.soil." + type.getName());
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setBlockName(blockName);
|
||||
setRegistryName(blockName);
|
||||
setTickRandomly(true);
|
||||
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f);
|
||||
setLightOpacity(255);
|
||||
setHardness(0.5f);
|
||||
setStepSound(Block.soundTypeGravel);
|
||||
setSoundType(SoundType.GROUND);
|
||||
}
|
||||
|
||||
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
|
||||
return acid.ordinal() * 3 + moisture.ordinal();
|
||||
}
|
||||
|
||||
public static String getPH(ItemStack stack, boolean withColor, boolean byNeutralNone) {
|
||||
EnumAcidity ph = EnumAcidity.values()[stack.getItemDamage() / 3];
|
||||
if (byNeutralNone) {
|
||||
if (ph == EnumAcidity.NEUTRAL) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return TextFormatting.GRAY + I18N.localise("botany.ph") + ": " + ph.getLocalisedName(withColor);
|
||||
}
|
||||
|
||||
public static String getMoisture(ItemStack stack, boolean withColor, boolean byNormalNone) {
|
||||
EnumMoisture moisure = EnumMoisture.values()[stack.getItemDamage() % 3];
|
||||
if (byNormalNone) {
|
||||
if (moisure == EnumMoisture.NORMAL) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return TextFormatting.GRAY + I18N.localise("botany.moisture") + ": " + moisure.getLocalisedName(withColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
switch (side) {
|
||||
case UP:
|
||||
return true;
|
||||
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case WEST:
|
||||
case EAST:
|
||||
IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
|
||||
Block block = iblockstate.getBlock();
|
||||
return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH && block != this;
|
||||
}
|
||||
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return super.getUnlocalizedName().replaceFirst("tile.", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
@@ -62,153 +143,172 @@ public class BlockSoil extends Block implements IBlockSoil {
|
||||
|
||||
@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));
|
||||
}
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (EnumAcidity acidity : EnumAcidity.values()) {
|
||||
for (EnumMoisture moisture : EnumMoisture.values()) {
|
||||
String modelName = "";
|
||||
if (acidity != EnumAcidity.NEUTRAL) {
|
||||
modelName += acidity.getName();
|
||||
}
|
||||
|
||||
@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];
|
||||
}
|
||||
if (moisture != EnumMoisture.NORMAL) {
|
||||
if (!modelName.isEmpty()) {
|
||||
modelName += "_";
|
||||
}
|
||||
modelName += moisture.getName();
|
||||
}
|
||||
|
||||
@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");
|
||||
if (modelName.isEmpty()) {
|
||||
modelName = "normal";
|
||||
}
|
||||
|
||||
String identifier;
|
||||
if (weedKilled) {
|
||||
identifier = type.getName() + "_no_weed/" + modelName;
|
||||
} else {
|
||||
identifier = type.getName() + "/" + modelName;
|
||||
}
|
||||
manager.registerItemModel(item, moisture.ordinal() + acidity.ordinal() * 3, identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, MOISTURE, ACIDITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return getMeta(state.getValue(ACIDITY), state.getValue(MOISTURE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
return getDefaultState().withProperty(MOISTURE, moisture).withProperty(ACIDITY, acidity);
|
||||
}
|
||||
|
||||
public EnumSoilType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
return damage;
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@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);
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
EnumMoisture moisture = state.getValue(MOISTURE);
|
||||
EnumMoisture desiredMoisture = BotanyCore.getGardening().getNaturalMoisture(world, pos);
|
||||
if (desiredMoisture.ordinal() > moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
|
||||
}
|
||||
if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
} else if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
|
||||
}
|
||||
|
||||
int meta2 = getMeta(acidity, moisture);
|
||||
if (meta != meta2) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta2, 2);
|
||||
IBlockState blockState = state.withProperty(MOISTURE, moisture);
|
||||
if (state != blockState) {
|
||||
world.setBlockState(pos, blockState, 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);
|
||||
|
||||
if (!weedKilled) {
|
||||
if (rand.nextInt(5 - getType(world, pos).ordinal()) != 0) {
|
||||
return;
|
||||
}
|
||||
pos = pos.up();
|
||||
if (!world.isAirBlock(pos)) {
|
||||
return;
|
||||
}
|
||||
world.setBlockState(pos, Botany.gardening().plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||
|
||||
if (worldIn.getBlockState(pos.up()).getMaterial().isSolid()) {
|
||||
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
public EnumAcidity getPH(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(ACIDITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
public EnumMoisture getMoisture(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(MOISTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAcidity getPH(World world, int x, int y, int z) {
|
||||
return EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMoisture getMoisture(World world, int x, int y, int z) {
|
||||
return EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSoilType getType(World world, int x, int y, int z) {
|
||||
public EnumSoilType getType(World world, BlockPos pos) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel) {
|
||||
EnumSoilType type = getType(world, x, y, z);
|
||||
public boolean fertilise(World world, BlockPos pos, EnumSoilType maxLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() >= maxLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return world.setBlock(x, y, z, Gardening.getSoilBlock(maxLevel, weedKilled), meta, 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel) {
|
||||
EnumSoilType type = getType(world, x, y, z);
|
||||
public boolean degrade(World world, BlockPos pos, EnumSoilType minLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() <= minLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return world.setBlock(x, y, z, Gardening.getSoilBlock(minLevel, weedKilled), meta, 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 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);
|
||||
public boolean setPH(World world, BlockPos pos, EnumAcidity pH) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(ACIDITY, pH));
|
||||
}
|
||||
|
||||
@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);
|
||||
public boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(MOISTURE, moisture));
|
||||
}
|
||||
|
||||
@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);
|
||||
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
|
||||
super.onNeighborChange(world, pos, neighbor);
|
||||
if (world.isSideSolid(pos.up(), EnumFacing.DOWN, false)) {
|
||||
((World) world).setBlockState(pos, Blocks.DIRT.getDefaultState(), 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) {
|
||||
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) {
|
||||
IBlockState plant = plantable.getPlant(world, pos.up());
|
||||
if (plant.getBlock() == Botany.flower) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plant == Botany.plant) {
|
||||
return !weedKilled || !BlockPlant.isWeed(world, x, y, z);
|
||||
if (plant.getBlock() == Botany.gardening().plant) {
|
||||
return !weedKilled || !BlockPlant.isWeed(world, pos);
|
||||
}
|
||||
return world instanceof World
|
||||
&& Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable);
|
||||
return world instanceof World && Blocks.DIRT.canSustainPlant(state, world, pos, direction, plantable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resistsWeeds(World world, int x, int y, int z) {
|
||||
public boolean resistsWeeds(World world, BlockPos pos) {
|
||||
return weedKilled;
|
||||
}
|
||||
|
||||
public boolean isWeedKilled() {
|
||||
return weedKilled;
|
||||
}
|
||||
}
|
||||
@@ -1,213 +1,197 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.gardening.IBlockSoil;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
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 implements IGardeningManager {
|
||||
private final Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>();
|
||||
private final Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>();
|
||||
private final Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>();
|
||||
|
||||
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 Gardening() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public static boolean isSoil(Block block) {
|
||||
@Override
|
||||
public boolean isSoil(Block block) {
|
||||
return block instanceof IBlockSoil;
|
||||
}
|
||||
|
||||
public static boolean isSoil(Item item) {
|
||||
return item instanceof ItemBlock
|
||||
&& isSoil(((ItemBlock) item).field_150939_a);
|
||||
@Override
|
||||
public boolean isSoil(Item item) {
|
||||
return item instanceof ItemBlock && isSoil(((ItemBlock) item).getBlock());
|
||||
}
|
||||
|
||||
public static EnumMoisture getNaturalMoisture(World world, int x, int y, int z) {
|
||||
float bias = getBiomeMoisture(world.getBiomeGenForCoords(x, z), y);
|
||||
@Override
|
||||
public boolean isSoil(ItemStack item) {
|
||||
return isSoil(item.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMoisture getNaturalMoisture(World world, BlockPos pos) {
|
||||
float bias = getBiomeMoisture(world, pos);
|
||||
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) {
|
||||
if (world.getBlockState(pos.add(dx, 0, dz)) == Blocks.SAND) {
|
||||
bias -= 1.5;
|
||||
} else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) {
|
||||
} else if (world.getBlockState(pos.add(dx, 0, dz)) == Blocks.WATER) {
|
||||
bias += 1.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) {
|
||||
if (world.isRaining() && world.canBlockSeeSky(pos.up()) && world.getPrecipitationHeight(pos).getY() <= pos.getY() + 1) {
|
||||
bias += 1.5;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (world.getBlockState(pos.add(dx, 0, dz)).getBlock() == Blocks.GRAVEL && bias > 0.0f) {
|
||||
bias *= 0.4f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bias <= -1.0f) {
|
||||
return EnumMoisture.DRY;
|
||||
}
|
||||
return (bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL;
|
||||
return (bias <= -1.0f) ? EnumMoisture.DRY : ((bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL);
|
||||
}
|
||||
|
||||
public static EnumAcidity getNaturalPH(World world, int x, int y, int z) {
|
||||
float bias = getBiomePH(world.getBiomeGenForCoords(x, z), y);
|
||||
@Override
|
||||
public EnumAcidity getNaturalPH(World world, BlockPos pos) {
|
||||
float bias = getBiomePH(world, pos);
|
||||
if (bias <= -1.0f) {
|
||||
return EnumAcidity.ACID;
|
||||
}
|
||||
return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL;
|
||||
}
|
||||
|
||||
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);
|
||||
@Override
|
||||
public float getBiomeMoisture(World world, BlockPos pos) {
|
||||
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
|
||||
double humidity = info.getHumidity();
|
||||
double temperature = info.getTemperature();
|
||||
double m = 3.2 * (humidity - 0.5) - 0.4 * (1.0 + temperature + 0.5 * temperature * temperature) + 1.1 - 1.6 * (temperature - 0.9) * (temperature - 0.9) - 0.002 * (pos.getY() - 64);
|
||||
return (float) ((m == 0.0) ? m : ((m < 0.0) ? (-Math.sqrt(m * m)) : Math.sqrt(m * m)));
|
||||
}
|
||||
|
||||
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);
|
||||
@Override
|
||||
public float getBiomePH(World world, BlockPos pos) {
|
||||
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
|
||||
double humidity = info.getHumidity();
|
||||
double temperature = info.getTemperature();
|
||||
return (float) (-3.0 * (humidity - 0.5) + 0.5 * (temperature - 0.699999988079071) * (temperature - 0.699999988079071) + 0.02f * (pos.getY() - 64) - 0.15000000596046448);
|
||||
}
|
||||
|
||||
public static void createSoil(World world, int x, int y, int z, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
|
||||
@Override
|
||||
public void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
|
||||
int meta = moisture.ordinal() + acidity.ordinal() * 3;
|
||||
world.setBlock(x, y, z, getSoilBlock(soil), meta, 2);
|
||||
world.setBlockState(pos, getSoilBlock(soil).getStateFromMeta(meta), 2);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
tryGrowSection(world, x, y, z);
|
||||
return true;
|
||||
@Override
|
||||
public Collection<ItemStack> getAcidFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserAcid.keySet());
|
||||
}
|
||||
|
||||
public static void tryGrowSection(World world, int x, int y, int z) {
|
||||
if (!BinnieCore.proxy.isSimulating(world)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity flower = world.getTileEntity(x, y, z);
|
||||
if (flower == null || !(flower instanceof TileEntityFlower)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public Collection<ItemStack> getAlkalineFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserAlkaline.keySet());
|
||||
}
|
||||
|
||||
public static void onGrowFromSeed(World world, int x, int y, int z) {
|
||||
tryGrowSection(world, x, y, z);
|
||||
@Override
|
||||
public Collection<ItemStack> getNutrientFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserNutrient.keySet());
|
||||
}
|
||||
|
||||
public static Collection<ItemStack> getAcidFertilisers() {
|
||||
return Gardening.fertiliserAcid.keySet();
|
||||
@Override
|
||||
public void registerAcidFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedAcidFertilisers.put(stack, strength);
|
||||
fertiliserAcid.put(stack, strength);
|
||||
}
|
||||
|
||||
public static Collection<ItemStack> getAlkalineFertilisers() {
|
||||
return Gardening.fertiliserAlkaline.keySet();
|
||||
@Override
|
||||
public void registerAlkalineFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(stack, strength);
|
||||
fertiliserAlkaline.put(stack, strength);
|
||||
}
|
||||
|
||||
public static Collection<ItemStack> getNutrientFertilisers() {
|
||||
return Gardening.fertiliserNutrient.keySet();
|
||||
@Override
|
||||
public void registerNutrientFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedNutrientFertilisers.put(stack, strength);
|
||||
fertiliserNutrient.put(stack, strength);
|
||||
}
|
||||
|
||||
public static boolean isAcidFertiliser(ItemStack itemstack) {
|
||||
@Override
|
||||
public boolean isAcidFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getAcidFertilisers()) {
|
||||
if (stack != null && stack.isItemEqual(itemstack)) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAlkalineFertiliser(ItemStack itemstack) {
|
||||
@Override
|
||||
public boolean isAlkalineFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getAlkalineFertilisers()) {
|
||||
if (stack != null && stack.isItemEqual(itemstack)) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isNutrientFertiliser(ItemStack itemstack) {
|
||||
@Override
|
||||
public boolean isNutrientFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getNutrientFertilisers()) {
|
||||
if (stack != null && stack.isItemEqual(itemstack)) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getFertiliserStrength(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAcid.entrySet()) {
|
||||
@Override
|
||||
public int getFertiliserStrength(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserAcid.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAlkaline.entrySet()) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserAlkaline.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserNutrient.entrySet()) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserNutrient.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
@@ -215,59 +199,73 @@ public class Gardening {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static boolean canTolerate(IFlower flower, World world, int x, int y, int z) {
|
||||
if (flower == null || flower.getGenome() == null) {
|
||||
@Override
|
||||
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
|
||||
if (flower == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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));
|
||||
IBlockState soil = world.getBlockState(pos.down());
|
||||
Block soilBlock = soil.getBlock();
|
||||
int soilMeta = soilBlock.getMetaFromState(soil);
|
||||
Biome biome = world.getBiome(pos);
|
||||
return canTolerate(
|
||||
flower,
|
||||
EnumAcidity.values()[soilMeta / 3 % 3],
|
||||
EnumMoisture.values()[soilMeta % 3],
|
||||
EnumTemperature.getFromValue(biome.getTemperature())
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
@Override
|
||||
public EnumSoilType getSoilType(World world, BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock() instanceof IBlockSoil) {
|
||||
return ((IBlockSoil) world.getBlockState(pos).getBlock()).getType(world, pos);
|
||||
}
|
||||
return EnumSoilType.SOIL;
|
||||
}
|
||||
|
||||
public static Block getSoilBlock(EnumSoilType type) {
|
||||
@Override
|
||||
public Block getSoilBlock(EnumSoilType type) {
|
||||
return getSoilBlock(type, false);
|
||||
}
|
||||
|
||||
public static Block getSoilBlock(EnumSoilType type, boolean weedkill) {
|
||||
@Override
|
||||
public Block getSoilBlock(EnumSoilType type, boolean weedKill) {
|
||||
switch (type) {
|
||||
case FLOWERBED:
|
||||
return weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed;
|
||||
return weedKill ? Botany.gardening().flowerbedNoWeed : Botany.gardening().flowerbed;
|
||||
|
||||
case LOAM:
|
||||
return weedkill ? Botany.loamNoWeed : Botany.loam;
|
||||
return weedKill ? Botany.gardening().loamNoWeed : Botany.gardening().loam;
|
||||
}
|
||||
return weedkill ? Botany.soilNoWeed : Botany.soil;
|
||||
return weedKill ? Botany.gardening().soilNoWeed : Botany.gardening().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);
|
||||
@Override
|
||||
public boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature) {
|
||||
return flower.getGenome().canTolerate(acidity)
|
||||
&& flower.getGenome().canTolerate(moisture)
|
||||
&& flower.getGenome().canTolerate(temperature);
|
||||
}
|
||||
|
||||
public static boolean isWeedkiller(ItemStack heldItem) {
|
||||
return heldItem != null
|
||||
&& heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
|
||||
@Override
|
||||
public boolean isWeedkiller(ItemStack heldItem) {
|
||||
return 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)) {
|
||||
@Override
|
||||
public boolean addWeedKiller(World world, BlockPos pos) {
|
||||
if (!(world.getBlockState(pos).getBlock() instanceof IBlockSoil)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumSoilType type = getSoilType(world, x, y, z);
|
||||
EnumSoilType type = getSoilType(world, pos);
|
||||
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);
|
||||
IBlockState oldState = world.getBlockState(pos);
|
||||
IBlockState newState = block.getStateFromMeta(oldState.getBlock().getMetaFromState(oldState));
|
||||
boolean done = world.setBlockState(pos, newState, 2);
|
||||
if (done && BlockPlant.isWeed(world, pos.up())) {
|
||||
world.setBlockToAir(pos.up());
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -1,86 +1,57 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
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 javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemSoil extends ItemBlock {
|
||||
protected EnumSoilType type;
|
||||
private final EnumSoilType type;
|
||||
private final boolean noWeed;
|
||||
|
||||
private boolean noWeed;
|
||||
|
||||
public ItemSoil(Block block) {
|
||||
public ItemSoil(BlockSoil block) {
|
||||
super(block);
|
||||
type = ((BlockSoil) field_150939_a).getType();
|
||||
noWeed = ((BlockSoil) field_150939_a).weedKilled;
|
||||
type = block.getType();
|
||||
noWeed = block.isWeedKilled();
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@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];
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
String info = "";
|
||||
|
||||
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.ACID) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.ph.acid")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.ALKALINE) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.ph.alkaline")
|
||||
+ EnumChatFormatting.RESET;
|
||||
info += BlockSoil.getMoisture(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
|
||||
info += BlockSoil.getPH(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
tooltip.add(info);
|
||||
}
|
||||
|
||||
if (noWeed) {
|
||||
tooltip.add(I18N.localise("botany.soil.weedkiller"));
|
||||
tooltip.add(TextFormatting.GREEN + I18N.localise("botany.soil.weedkiller"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
String soilName = type.name().toLowerCase(Locale.ENGLISH);
|
||||
return I18N.localise("botany.soil." + soilName);
|
||||
return getUnlocalizedNameInefficiently(stack).trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,93 @@
|
||||
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 binnie.core.BinnieCore;
|
||||
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.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSoilMeter extends Item {
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemSoilMeter extends Item implements IItemModelRegister {
|
||||
public ItemSoilMeter() {
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName("soilMeter");
|
||||
setUnlocalizedName("botany.soil_meter");
|
||||
setMaxStackSize(1);
|
||||
setRegistryName("soil_meter");
|
||||
}
|
||||
|
||||
@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 static String getPH(ItemStack stack, boolean withColor, boolean byNeutralNone) {
|
||||
EnumAcidity ph = EnumAcidity.values()[stack.getItemDamage() / 3];
|
||||
if (byNeutralNone) {
|
||||
if (ph == EnumAcidity.NEUTRAL) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
return TextFormatting.GRAY + I18N.localise("botany.ph") + ": " + ph.getLocalisedName(withColor);
|
||||
}
|
||||
|
||||
public static String getMoisture(ItemStack stack, boolean withColor, boolean byNormalNone) {
|
||||
EnumMoisture moisure = EnumMoisture.values()[stack.getItemDamage() % 3];
|
||||
if (byNormalNone) {
|
||||
if (moisure == EnumMoisture.NORMAL) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return TextFormatting.GRAY + I18N.localise("botany.moisture") + ": " + moisure.getLocalisedName(withColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
itemIcon = Botany.proxy.getIcon(register, "soilMeter");
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise("botany.item.soilMeter.name");
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
if (!gardening.isSoil(block)) {
|
||||
pos = pos.down();
|
||||
block = worldIn.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
if (!gardening.isSoil(block)) {
|
||||
pos = pos.down();
|
||||
block = worldIn.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
if (gardening.isSoil(block) && !BinnieCore.getBinnieProxy().isSimulating(worldIn)) {
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
String info = I18N.localise("botany.soil.type") + ": "
|
||||
+ soil.getType(worldIn, pos).getTranslated() + ", "
|
||||
+ TextFormatting.WHITE + I18N.localise("botany.moisture") + ": "
|
||||
+ soil.getMoisture(worldIn, pos).getLocalisedName(true) + ", "
|
||||
+ TextFormatting.WHITE + I18N.localise("botany.ph") + ": "
|
||||
+ soil.getPH(worldIn, pos).getLocalisedName(true);
|
||||
|
||||
ITextComponent chat = new TextComponentString(info);
|
||||
player.sendStatusMessage(chat, false);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,98 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
import binnie.Constants;
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class ItemTrowel extends Item {
|
||||
protected Item.ToolMaterial theToolMaterial;
|
||||
String locName;
|
||||
public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
protected final ToolMaterial theToolMaterial;
|
||||
protected final String modelName;
|
||||
|
||||
public ItemTrowel(Item.ToolMaterial toolMaterial, String material) {
|
||||
public ItemTrowel(ToolMaterial toolMaterial, String materialName) {
|
||||
theToolMaterial = toolMaterial;
|
||||
maxStackSize = 1;
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(toolMaterial.getMaxUses());
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName("trowel" + material);
|
||||
locName = "trowel" + material;
|
||||
modelName = "trowel_" + materialName;
|
||||
setUnlocalizedName("botany." + modelName);
|
||||
setRegistryName(modelName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
itemIcon = Botany.proxy.getIcon(register, "tools/" + locName);
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, new ItemTrowelMeshDefinition());
|
||||
ModelBakery.registerItemVariants(item, new ResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + modelName));
|
||||
}
|
||||
|
||||
@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;
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!player.canPlayerEdit(pos, facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
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;
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
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);
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (worldIn.isRemote) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos);
|
||||
EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos);
|
||||
gardening.plantSoil(worldIn, pos, EnumSoilType.SOIL, moisture, acidity);
|
||||
stack.damageItem(1, player);
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", theToolMaterial.getDamageVsEntity() + 0.5, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -1.5, 0));
|
||||
}
|
||||
|
||||
return multimap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,4 +100,16 @@ public class ItemTrowel extends Item {
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getToolMaterialName() {
|
||||
return theToolMaterial.toString();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class ItemTrowelMeshDefinition implements ItemMeshDefinition {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + modelName, "inventory");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
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 binnie.core.util.I18N;
|
||||
|
||||
public class ItemWeed extends ItemBlock {
|
||||
public ItemWeed(Block block) {
|
||||
@@ -16,17 +15,11 @@ public class ItemWeed extends ItemBlock {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
|
||||
return I18N.localise("botany.plant." + PlantType.values()[stack.getItemDamage()].getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return field_150939_a.getIcon(2, damage);
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,43 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import binnie.Binnie;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.flower.EnumTubeInsulate;
|
||||
import binnie.botany.flower.EnumTubeMaterial;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
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.IGardeningManager;
|
||||
import binnie.botany.ceramic.BlockCeramic;
|
||||
import binnie.botany.ceramic.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.BlockCeramicPatterned;
|
||||
import binnie.botany.ceramic.BlockStained;
|
||||
import binnie.botany.ceramic.BlockStainedGlass;
|
||||
import binnie.botany.ceramic.CeramicTileRecipe;
|
||||
import binnie.botany.ceramic.ItemCeramic;
|
||||
import binnie.botany.ceramic.ItemStainedGlass;
|
||||
import binnie.botany.ceramic.PigmentRecipe;
|
||||
import binnie.botany.ceramic.TileCeramic;
|
||||
import binnie.botany.ceramic.brick.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.brick.ItemCeramicBrick;
|
||||
import binnie.botany.ceramic.brick.TileCeramicBrick;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.farm.CircuitGarden;
|
||||
import binnie.botany.flower.ItemInsulatedTube;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
@@ -21,100 +47,124 @@ import binnie.botany.items.ItemPigment;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.IInitializable;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import binnie.core.block.ItemMetadataRenderer;
|
||||
import binnie.core.block.MultipassItemRenderer;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
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;
|
||||
import binnie.core.item.ItemMisc;
|
||||
import binnie.extratrees.carpentry.ItemDesign;
|
||||
|
||||
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<>();
|
||||
public static final HashMap<ItemStack, Integer> queuedAcidFertilisers = new HashMap<>();
|
||||
public static final HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>();
|
||||
public static final HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>();
|
||||
|
||||
public BlockPlant plant;
|
||||
public ItemTrowel trowelWood;
|
||||
public ItemTrowel trowelStone;
|
||||
public ItemTrowel trowelIron;
|
||||
public ItemTrowel trowelDiamond;
|
||||
public ItemTrowel trowelGold;
|
||||
public BlockSoil soil;
|
||||
public BlockSoil loam;
|
||||
public BlockSoil flowerbed;
|
||||
public BlockSoil soilNoWeed;
|
||||
public BlockSoil loamNoWeed;
|
||||
public BlockSoil flowerbedNoWeed;
|
||||
public ItemInsulatedTube insulatedTube;
|
||||
public ItemSoilMeter soilMeter;
|
||||
public ItemMisc misc;
|
||||
public ItemPigment pigment;
|
||||
public ItemClay clay;
|
||||
public BlockCeramic ceramic;
|
||||
public BlockCeramicPatterned ceramicTile;
|
||||
public BlockStainedGlass stained;
|
||||
public BlockCeramicBrick ceramicBrick;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
Botany.plant = new BlockPlant();
|
||||
GameRegistry.registerBlock(Botany.plant, ItemWeed.class, "plant");
|
||||
plant = new BlockPlant();
|
||||
soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
|
||||
loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
|
||||
flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
|
||||
soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soil_no_weed", true);
|
||||
loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loam_no_weed", true);
|
||||
flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed_no_weed", true);
|
||||
soilMeter = new ItemSoilMeter();
|
||||
insulatedTube = new ItemInsulatedTube();
|
||||
trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "wood");
|
||||
trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "stone");
|
||||
trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "iron");
|
||||
trowelDiamond = new ItemTrowel(Item.ToolMaterial.DIAMOND, "diamond");
|
||||
trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "gold");
|
||||
misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
|
||||
pigment = new ItemPigment();
|
||||
clay = new ItemClay();
|
||||
ceramic = new BlockCeramic();
|
||||
stained = new BlockStainedGlass();
|
||||
ceramicTile = new BlockCeramicPatterned();
|
||||
ceramicBrick = new BlockCeramicBrick();
|
||||
|
||||
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
|
||||
GameRegistry.registerBlock(Botany.soil, ItemSoil.class, "soil");
|
||||
Botany.proxy.registerBlock(plant, new ItemWeed(plant));
|
||||
Botany.proxy.registerBlock(soil, new ItemSoil(soil));
|
||||
Botany.proxy.registerBlock(loam, new ItemSoil(loam));
|
||||
Botany.proxy.registerBlock(flowerbed, new ItemSoil(flowerbed));
|
||||
Botany.proxy.registerBlock(soilNoWeed, new ItemSoil(soilNoWeed));
|
||||
Botany.proxy.registerBlock(loamNoWeed, new ItemSoil(loamNoWeed));
|
||||
Botany.proxy.registerBlock(flowerbedNoWeed, new ItemSoil(flowerbedNoWeed));
|
||||
Botany.proxy.registerItem(soilMeter);
|
||||
Botany.proxy.registerItem(insulatedTube);
|
||||
Botany.proxy.registerItem(trowelWood);
|
||||
Botany.proxy.registerItem(trowelStone);
|
||||
Botany.proxy.registerItem(trowelIron);
|
||||
Botany.proxy.registerItem(trowelDiamond);
|
||||
Botany.proxy.registerItem(trowelGold);
|
||||
Botany.proxy.registerItem(misc);
|
||||
Botany.proxy.registerItem(pigment);
|
||||
Botany.proxy.registerItem(clay);
|
||||
Botany.proxy.registerBlock(ceramic, new ItemCeramic(ceramic));
|
||||
Botany.proxy.registerBlock(stained, new ItemStainedGlass(stained));
|
||||
Botany.proxy.registerBlock(ceramicTile, new ItemDesign(ceramicTile));
|
||||
Botany.proxy.registerBlock(ceramicBrick, new ItemCeramicBrick(ceramicBrick));
|
||||
|
||||
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
|
||||
GameRegistry.registerBlock(Botany.loam, ItemSoil.class, "loam");
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramic.class, "botany.tile.ceramic");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramic), new ItemMetadataRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(stained), new ItemMetadataRenderer());
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramicBrick.class, "botany.tile.ceramicBrick");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramicTile), new MultipassItemRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramicBrick), new MultipassItemRenderer());
|
||||
|
||||
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
|
||||
GameRegistry.registerBlock(Botany.flowerbed, ItemSoil.class, "flowerbed");
|
||||
|
||||
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soilNoWeed", true);
|
||||
GameRegistry.registerBlock(Botany.soilNoWeed, ItemSoil.class, "soilNoWeed");
|
||||
|
||||
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loamNoWeed", true);
|
||||
GameRegistry.registerBlock(Botany.loamNoWeed, ItemSoil.class, "loamNoWeed");
|
||||
|
||||
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbedNoWeed", true);
|
||||
GameRegistry.registerBlock(Botany.flowerbedNoWeed, ItemSoil.class, "flowerbedNoWeed");
|
||||
|
||||
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.ceramic = new BlockCeramic();
|
||||
GameRegistry.registerBlock(Botany.ceramic, ItemMetadata.class, "ceramic");
|
||||
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
|
||||
|
||||
Botany.stained = new BlockStained();
|
||||
GameRegistry.registerBlock(Botany.stained, ItemMetadata.class, "stained");
|
||||
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
|
||||
|
||||
Botany.ceramicTile = new BlockCeramicPatterned();
|
||||
GameRegistry.registerBlock(Botany.ceramicTile, ItemMetadata.class, "ceramicPattern");
|
||||
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
|
||||
|
||||
Botany.ceramicBrick = new BlockCeramicBrick();
|
||||
GameRegistry.registerBlock(Botany.ceramicBrick, ItemMetadata.class, "ceramicBrick");
|
||||
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
|
||||
OreDictionary.registerOre("pigment", pigment);
|
||||
OreDictionary.registerOre("toolTrowel", trowelWood);
|
||||
OreDictionary.registerOre("toolTrowel", trowelStone);
|
||||
OreDictionary.registerOre("toolTrowel", trowelIron);
|
||||
OreDictionary.registerOre("toolTrowel", trowelGold);
|
||||
OreDictionary.registerOre("toolTrowel", trowelDiamond);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
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);
|
||||
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);
|
||||
ItemStack icon;
|
||||
if (moist == EnumMoisture.DRY) {
|
||||
icon = yellow;
|
||||
} else if (moist == EnumMoisture.NORMAL) {
|
||||
icon = red;
|
||||
} else {
|
||||
icon = blue;
|
||||
}
|
||||
int insulate = 2 - moist.ordinal();
|
||||
if (fertilised) {
|
||||
insulate += 3;
|
||||
}
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 0 + 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);
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(insulatedTube, 1, 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(insulatedTube, 1, 1 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(insulatedTube, 1, 2 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(insulatedTube, 1, 3 + 128 * insulate), icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,154 +172,163 @@ public class ModuleGardening implements IInitializable {
|
||||
|
||||
@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);
|
||||
RecipeUtil recipeUtil = new RecipeUtil(Constants.BOTANY_MOD_ID);
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
ForgeRegistries.RECIPES.register(new CeramicTileRecipe());
|
||||
for (EnumTubeMaterial mat: EnumTubeMaterial.VALUES) {
|
||||
for (EnumTubeInsulate insulate : EnumTubeInsulate.VALUES) {
|
||||
ItemStack tubes = new ItemStack(insulatedTube, 2, mat.ordinal() + 128 * insulate.ordinal());
|
||||
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
|
||||
ItemStack forestryTube = new ItemStack(Mods.forestry.item("thermionicTubes"), 1, mat);
|
||||
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
|
||||
ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat.ordinal());
|
||||
String recipeName = "thermionic_tubes_" + insulate.getUid() + "_" + mat.getUid();
|
||||
recipeUtil.addShapelessRecipe(recipeName, tubes, forestryTube, forestryTube, insulateStack);
|
||||
}
|
||||
}
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelWood,
|
||||
new Object[]{
|
||||
recipeUtil.addRecipe("trowel_wood",
|
||||
trowelWood,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.dirt,
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "plankWood"
|
||||
}
|
||||
));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelStone,
|
||||
new Object[]{
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_stone",
|
||||
trowelStone,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.dirt,
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "cobblestone"
|
||||
}
|
||||
));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelIron,
|
||||
new Object[]{
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_iron",
|
||||
trowelIron,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.dirt,
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotIron"
|
||||
}
|
||||
));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelGold,
|
||||
new Object[]{
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_gold",
|
||||
trowelGold,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.dirt,
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotGold"
|
||||
}
|
||||
));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelDiamond,
|
||||
new Object[]{
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_diamond",
|
||||
trowelDiamond,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.dirt,
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "gemDiamond"
|
||||
}
|
||||
));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.soilMeter,
|
||||
new Object[]{
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("soil_meter",
|
||||
soilMeter,
|
||||
" 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(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 ShapelessOreRecipe(
|
||||
new ItemStack(Botany.pigment, 2, EnumFlowerColor.BLACK.ordinal()),
|
||||
new Object[]{
|
||||
"pigment",
|
||||
"pigment",
|
||||
"dyeBlack"
|
||||
}
|
||||
));
|
||||
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);
|
||||
|
||||
recipeUtil.addShapelessRecipe("weed_killer",
|
||||
BotanyItems.WEEDKILLER.get(4),
|
||||
new ItemStack(Items.SPIDER_EYE),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS)
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_ash",
|
||||
BotanyItems.POWDER_ASH.get(4),
|
||||
Mods.Forestry.stack("ash")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_mulch",
|
||||
BotanyItems.POWDER_MULCH.get(4),
|
||||
Mods.Forestry.stack("mulch")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_compost",
|
||||
BotanyItems.POWDER_COMPOST.get(4),
|
||||
Mods.Forestry.stack("fertilizer_bio")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_fertilizer",
|
||||
BotanyItems.POWDER_FERTILISER.get(4),
|
||||
Mods.Forestry.stack("fertilizer_compound")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_pulp",
|
||||
BotanyItems.POWDER_PULP.get(4),
|
||||
Mods.Forestry.stack("wood_pulp")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_sulphur",
|
||||
BotanyItems.POWDER_SULPHUR.get(4),
|
||||
"dustSulphur"
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("pigment_black",
|
||||
new ItemStack(pigment, 2, EnumFlowerColor.Black.ordinal()),
|
||||
"pigment", "pigment", "dyeBlack"
|
||||
);
|
||||
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_SULPHUR.get(1), 1);
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_MULCH.get(1), 1);
|
||||
gardening.registerAcidFertiliser(Mods.Forestry.stack("mulch"), 2);
|
||||
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
ModuleGardening.queuedAcidFertilisers.put(stack, 2);
|
||||
gardening.registerAcidFertiliser(stack, 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);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_ASH.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_PULP.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("ash"), 2);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("wood_pulp"), 2);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_COMPOST.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_FERTILISER.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_bio"), 2);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_compound"), 2);
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
addAcidFertiliser(entry.getKey(), entry.getValue());
|
||||
addAcidFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
|
||||
addAlkalineFertiliser(entry.getKey(), entry.getValue());
|
||||
addAlkalineFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
|
||||
addNutrientFertiliser(entry.getKey(), entry.getValue());
|
||||
addNutrientFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
GameRegistry.addRecipe(
|
||||
BotanyItems.Mortar.get(6),
|
||||
" c ", "cgc", " c ",
|
||||
'c', Items.clay_ball,
|
||||
'g', Blocks.gravel
|
||||
);
|
||||
recipeUtil.addRecipe("mortar", BotanyItems.MORTAR.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL);
|
||||
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);
|
||||
ItemStack clay = new ItemStack(this.clay, 1, c.ordinal());
|
||||
ItemStack pigment = new ItemStack(this.pigment, 1, c.ordinal());
|
||||
recipeUtil.addShapelessRecipe("clay_" + c.getIdent(), clay, Items.CLAY_BALL, Items.CLAY_BALL, Items.CLAY_BALL, pigment);
|
||||
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(ceramic, c.ordinal()), 0.0f);
|
||||
ItemStack glass = TileEntityMetadata.getItemStack(stained, c.ordinal());
|
||||
glass.setCount(4);
|
||||
|
||||
recipeUtil.addRecipe("mortar_" + c.getIdent(),
|
||||
glass,
|
||||
" g ", "gpg", " g ",
|
||||
'g', Blocks.GLASS,
|
||||
'p', pigment
|
||||
);
|
||||
}
|
||||
GameRegistry.addRecipe(new PigmentRecipe());
|
||||
ForgeRegistries.RECIPES.register(new PigmentRecipe());
|
||||
}
|
||||
|
||||
private ItemStack getStack(int type, int pH, int moisture) {
|
||||
if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) {
|
||||
return null;
|
||||
if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) {
|
||||
return new ItemStack(BotanyCore.getGardening().getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
|
||||
}
|
||||
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private void addAcidFertiliser(ItemStack stack, int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gardening.fertiliserAcid.put(stack, strengthMax);
|
||||
private void addAcidFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
@@ -277,14 +336,15 @@ public class ModuleGardening implements IInitializable {
|
||||
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;
|
||||
if (!start.isEmpty() && !end.isEmpty()) {
|
||||
end.setCount(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);
|
||||
String recipeName = "acid_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
@@ -293,12 +353,7 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addAlkalineFertiliser(ItemStack stack, int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gardening.fertiliserAlkaline.put(stack, strengthMax);
|
||||
private void addAlkalineFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
@@ -306,14 +361,15 @@ public class ModuleGardening implements IInitializable {
|
||||
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;
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(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);
|
||||
String recipeName = "alkaline_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
@@ -322,12 +378,7 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addNutrientFertiliser(ItemStack stack, int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gardening.fertiliserNutrient.put(stack, strengthMax);
|
||||
private void addNutrientFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
@@ -335,14 +386,15 @@ public class ModuleGardening implements IInitializable {
|
||||
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;
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(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);
|
||||
String recipeName = "nutrient_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
|
||||
Loaded 100 of 2809 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user