mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 17:24:53 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -1,2 +0,0 @@
|
||||
# Ignore spotlessApply reformat
|
||||
91bf137a94d1207f943929e0881750a1b8c4f3bf
|
||||
@@ -1,44 +0,0 @@
|
||||
* text eol=lf
|
||||
|
||||
*.[jJ][aA][rR] binary
|
||||
|
||||
*.[pP][nN][gG] binary
|
||||
*.[jJ][pP][gG] binary
|
||||
*.[jJ][pP][eE][gG] binary
|
||||
*.[gG][iI][fF] binary
|
||||
*.[tT][iI][fF] binary
|
||||
*.[tT][iI][fF][fF] binary
|
||||
*.[iI][cC][oO] binary
|
||||
*.[sS][vV][gG] text
|
||||
*.[eE][pP][sS] binary
|
||||
*.[xX][cC][fF] binary
|
||||
|
||||
*.[kK][aA][rR] binary
|
||||
*.[mM]4[aA] binary
|
||||
*.[mM][iI][dD] binary
|
||||
*.[mM][iI][dD][iI] binary
|
||||
*.[mM][pP]3 binary
|
||||
*.[oO][gG][gG] binary
|
||||
*.[rR][aA] binary
|
||||
|
||||
*.7[zZ] binary
|
||||
*.[gG][zZ] binary
|
||||
*.[tT][aA][rR] binary
|
||||
*.[tT][gG][zZ] binary
|
||||
*.[zZ][iI][pP] binary
|
||||
|
||||
*.[tT][cC][nN] binary
|
||||
*.[sS][oO] binary
|
||||
*.[dD][lL][lL] binary
|
||||
*.[dD][yY][lL][iI][bB] binary
|
||||
*.[pP][sS][dD] binary
|
||||
*.[tT][tT][fF] binary
|
||||
*.[oO][tT][fF] binary
|
||||
|
||||
*.[pP][aA][tT][cC][hH] -text
|
||||
|
||||
*.[bB][aA][tT] text eol=crlf
|
||||
*.[cC][mM][dD] text eol=crlf
|
||||
*.[pP][sS]1 text eol=crlf
|
||||
|
||||
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main ]
|
||||
push:
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
|
||||
secrets: inherit
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
name: Release tagged build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: [ '*' ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release-tags:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
|
||||
secrets: inherit
|
||||
+24
-34
@@ -1,38 +1,28 @@
|
||||
# everything
|
||||
/*
|
||||
|
||||
.gradle
|
||||
.settings
|
||||
/.idea/
|
||||
/.vscode/
|
||||
/run/
|
||||
/build/
|
||||
/eclipse/
|
||||
.classpath
|
||||
.project
|
||||
/bin/
|
||||
/config/
|
||||
/crash-reports/
|
||||
/logs/
|
||||
options.txt
|
||||
/saves/
|
||||
usernamecache.json
|
||||
banned-ips.json
|
||||
banned-players.json
|
||||
eula.txt
|
||||
ops.json
|
||||
server.properties
|
||||
servers.dat
|
||||
usercache.json
|
||||
whitelist.json
|
||||
/out/
|
||||
# IntelliJ
|
||||
/build
|
||||
/run
|
||||
/out
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
src/main/resources/mixins.*([!.]).json
|
||||
*.bat
|
||||
*.DS_Store
|
||||
!gradlew.bat
|
||||
.factorypath
|
||||
addon.local.gradle
|
||||
addon.local.gradle.kts
|
||||
addon.late.local.gradle
|
||||
addon.late.local.gradle.kts
|
||||
layout.json
|
||||
classes/
|
||||
|
||||
|
||||
# folders
|
||||
!/gradle/wrapper
|
||||
!/src
|
||||
|
||||
# files
|
||||
!/.gitignore
|
||||
!/LICENSE.txt
|
||||
!/license-header.txt
|
||||
!/README.md
|
||||
!/gradle.properties
|
||||
!/build.gradle
|
||||
!/gradlew
|
||||
!/gradlew.bat
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: java
|
||||
jdk: oraclejdk8
|
||||
|
||||
before_cache:
|
||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/providedDummy.jar
|
||||
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/compileDummy.jar
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
|
||||
before_install: chmod +x gradlew
|
||||
install:
|
||||
- ./gradlew setupCIWorkspace -S
|
||||
script:
|
||||
- ./gradlew build
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
@@ -1,3 +0,0 @@
|
||||
# Any Github changes require admin approval
|
||||
/.github/** @GTNewHorizons/admin
|
||||
|
||||
+676
-1
@@ -1,7 +1,7 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -163,3 +163,678 @@ whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -1,46 +1,4 @@
|
||||
[Binnie mods](https://minecraft.curseforge.com/projects/binnies-mods/files)
|
||||
====================================
|
||||
|
||||
### 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.
|
||||
|
||||
### Homepage
|
||||
|
||||
[Wiki](https://binnie.mods.wiki/wiki/Main_Page)
|
||||
|
||||
[Latest Builds for 1.7.10](https://ci.bymarcin.com/job/Binnie-Mods-MC1.7.10/)
|
||||
|
||||
### 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
|
||||
|
||||
### Warning
|
||||
|
||||
Removed unused (unfinished) items and blocks: Honey Crystal, Alcohol, etc.
|
||||
|
||||
### Building
|
||||
## Binnie mods
|
||||
|
||||
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}
|
||||
|
||||
+90
-4
@@ -1,5 +1,91 @@
|
||||
//version: 1707058017
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhconvention'
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'idea'
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
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-1.11.2"
|
||||
|
||||
minecraft {
|
||||
version = mcversion + "-" + forgeversion
|
||||
mappings = mcp_mappings
|
||||
runDir = "run"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "jei"
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
name = "ic2, forestry"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
ivy {
|
||||
name 'JEI Bees'
|
||||
artifactPattern "http://addons-origin.cursecdn.com/files/${jeibees_cf}/[module]-[revision]-[classifier].[ext]"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "net.sengir.forestry:forestry_${mcversion}:${forestry_version}"
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile name: 'jeibees', version: jeibees_version, ext: 'jar', classifier: "dev"
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_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"
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
// 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.'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
{{/tags}}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:ForestryMC:4.8.8:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.2.10:dev')
|
||||
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.5.25-GTNH:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.39:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
|
||||
}
|
||||
+14
-188
@@ -1,192 +1,18 @@
|
||||
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
|
||||
# LOCAL to test local config updates.
|
||||
gtnh.settings.blowdryerTag = 0.2.0
|
||||
# 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
|
||||
|
||||
# Human-readable mod name, available for mcmod.info population.
|
||||
modName = Binnie Core
|
||||
mcversion=1.11.2
|
||||
forgeversion=13.20.0.2315
|
||||
mcp_mappings=snapshot_20161220
|
||||
|
||||
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
|
||||
# Conventionally lowercase.
|
||||
modId = BinnieCore
|
||||
forestry_version=5.3.4.119
|
||||
ic2_version=2.7.71-ex111
|
||||
|
||||
# Root package of the mod, used to find various classes in other properties,
|
||||
# mcmod.info substitution, enabling assertions in run tasks, etc.
|
||||
modGroup = binnie
|
||||
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
autoUpdateBuildScript = false
|
||||
|
||||
# Version of Minecraft to target
|
||||
minecraftVersion = 1.7.10
|
||||
|
||||
# Version of Minecraft Forge to target
|
||||
forgeVersion = 10.13.4.1614
|
||||
|
||||
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
|
||||
channel = stable
|
||||
|
||||
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
|
||||
mappingsVersion = 12
|
||||
|
||||
# Defines other MCP mappings for dependency deobfuscation.
|
||||
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
|
||||
# Select a default username for testing your mod. You can always override this per-run by running
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = false
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
enableGenericInjection = false
|
||||
|
||||
# Generate a class with a String field for the mod version named as defined below.
|
||||
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
|
||||
generateGradleTokenClass =
|
||||
|
||||
# Name of the token containing the project's current version to generate/replace.
|
||||
gradleTokenVersion = GRADLETOKEN_VERSION
|
||||
|
||||
# [DEPRECATED] Mod ID replacement token.
|
||||
gradleTokenModId =
|
||||
|
||||
# [DEPRECATED] Mod name replacement token.
|
||||
gradleTokenModName =
|
||||
|
||||
# [DEPRECATED] Mod Group replacement token.
|
||||
gradleTokenGroupName =
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...]).
|
||||
# Leave these properties empty to skip individual token replacements.
|
||||
replaceGradleTokenInFile = BinnieCore.java
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
||||
apiPackage =
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a space-separated list.
|
||||
# Example value: mymodid_at.cfg nei_at.cfg
|
||||
accessTransformersFile =
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = false
|
||||
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass =
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
containsMixinsAndOrCoreModOnly = false
|
||||
|
||||
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
||||
forceEnableMixins = false
|
||||
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
|
||||
# responsibility to check the license and request permission for distribution if required.
|
||||
usesShadowedDependencies = false
|
||||
|
||||
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
|
||||
# their own classes, making the minimization unreliable.
|
||||
minimizeShadowedDependencies = true
|
||||
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||
usesMavenPublishing = true
|
||||
|
||||
# Maven repository to publish the mod to.
|
||||
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
|
||||
|
||||
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
||||
#
|
||||
# The project's ID on Modrinth. Can be either the slug or the ID.
|
||||
# Leave this empty if you don't want to publish to Modrinth.
|
||||
modrinthProjectId =
|
||||
|
||||
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
||||
# Syntax: scope1-type1:name1;scope2-type2:name2;...
|
||||
# Where scope can be one of [required, optional, incompatible, embedded],
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
modrinthRelations =
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
#
|
||||
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
||||
# Leave this empty if you don't want to publish on CurseForge.
|
||||
curseForgeProjectId =
|
||||
|
||||
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
|
||||
# Syntax: type1:name1;type2:name2;...
|
||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||
# and the name is the CurseForge project slug of the other mod.
|
||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
curseForgeRelations =
|
||||
|
||||
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
|
||||
# projects. New projects should not use this parameter.
|
||||
customArchiveBaseName = binnie-mods
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
|
||||
# versionPattern =
|
||||
|
||||
# Uncomment to prevent the source code from being published.
|
||||
# noPublishedSources = true
|
||||
|
||||
# Uncomment this to disable Spotless checks.
|
||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
||||
# disableSpotless = true
|
||||
|
||||
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
|
||||
# disableCheckstyle = true
|
||||
|
||||
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# (force use delegated build).
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
|
||||
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
||||
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
||||
# ideaOverrideBuildType = idea
|
||||
|
||||
# Whether IDEA should run spotless checks when pressing the Build button.
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_patch=0
|
||||
|
||||
jei_version=4.5.0.287
|
||||
jeibees_cf=2376/963
|
||||
jeibees_version=0.9.0.4-mc1.11.2
|
||||
Vendored
BIN
Binary file not shown.
+2
-3
@@ -1,7 +1,6 @@
|
||||
#Mon Sep 14 12:28:28 PDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
||||
@@ -1,127 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
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
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
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
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
} >&2
|
||||
}
|
||||
|
||||
die () {
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -130,120 +81,84 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
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`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
Vendored
+40
-42
@@ -1,20 +1,4 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,29 +9,25 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
set DEFAULT_JVM_OPTS=-d64 -Xmx2G
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -55,36 +35,54 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
before_install:
|
||||
- ./gradlew setupCIWorkspace
|
||||
@@ -1,4 +0,0 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons")
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19'
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,16 @@ 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;
|
||||
|
||||
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,33 +1,48 @@
|
||||
package binnie.botany;
|
||||
|
||||
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.api.IFlowerRoot;
|
||||
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.brick.BlockCeramicBrick;
|
||||
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.ItemBotany;
|
||||
import binnie.botany.flower.ItemInsulatedTube;
|
||||
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;
|
||||
@@ -44,309 +59,268 @@ 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;
|
||||
|
||||
@Mod(
|
||||
modid = "Botany",
|
||||
name = "Botany",
|
||||
version = BinnieCore.VERSION,
|
||||
useMetadata = true,
|
||||
dependencies = "after:BinnieCore")
|
||||
@Mod(modid = Constants.BOTANY_MOD_ID, name = "Binnie's Botany", useMetadata = true, dependencies = "required-after:" + Constants.CORE_MOD_ID)
|
||||
public class Botany extends AbstractMod {
|
||||
public static final float AGE_CHANCE = 0.2f;
|
||||
|
||||
@Mod.Instance("Botany")
|
||||
public static Botany instance;
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Mod.Instance(Constants.BOTANY_MOD_ID)
|
||||
public static Botany instance;
|
||||
@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 ItemBotany flowerItem;
|
||||
public static ItemBotany seed;
|
||||
public static ItemBotany pollen;
|
||||
public static ItemDictionary database;
|
||||
/* MODULE GARDENING */
|
||||
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 ItemPigment pigment;
|
||||
public static ItemClay clay;
|
||||
public static BlockCeramic ceramic;
|
||||
public static BlockCeramicPatterned ceramicTile;
|
||||
public static BlockStainedGlass stained;
|
||||
public static BlockCeramicBrick ceramicBrick;
|
||||
@Nullable
|
||||
public static Item botanistBackpack;
|
||||
|
||||
@SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
|
||||
public static Proxy proxy;
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent evt) {
|
||||
this.preInit();
|
||||
}
|
||||
|
||||
public static BlockFlower flower;
|
||||
public static Item seed;
|
||||
public static Item pollen;
|
||||
public static ItemDictionary database;
|
||||
public static BlockPlant plant;
|
||||
public static ItemTrowel trowelWood;
|
||||
public static ItemTrowel trowelStone;
|
||||
public static ItemTrowel trowelIron;
|
||||
public static ItemTrowel trowelDiamond;
|
||||
public static ItemTrowel trowelGold;
|
||||
public static BlockSoil soil;
|
||||
public static BlockSoil loam;
|
||||
public static BlockSoil flowerbed;
|
||||
public static BlockSoil soilNoWeed;
|
||||
public static BlockSoil loamNoWeed;
|
||||
public static BlockSoil flowerbedNoWeed;
|
||||
public static ItemInsulatedTube insulatedTube;
|
||||
public static ItemSoilMeter soilMeter;
|
||||
public static ItemMisc misc;
|
||||
public static ItemFlower flowerItem;
|
||||
public static ItemPigment pigment;
|
||||
public static ItemClay clay;
|
||||
public static BlockCeramic ceramic;
|
||||
public static BlockCeramicPatterned ceramicTile;
|
||||
public static BlockStained stained;
|
||||
public static BlockCeramicBrick ceramicBrick;
|
||||
@Mod.EventHandler
|
||||
public void init(final FMLInitializationEvent evt) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
public Botany() {
|
||||
Botany.instance = this;
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent evt) {
|
||||
this.postInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
addModule(new ModuleCore());
|
||||
addModule(new ModuleGenetics());
|
||||
addModule(new ModuleGardening());
|
||||
preInit();
|
||||
}
|
||||
@Override
|
||||
protected void registerModules() {
|
||||
this.addModule(new ModuleCore());
|
||||
this.addModule(new ModuleGenetics());
|
||||
this.addModule(new ModuleGardening());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
init();
|
||||
}
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BotanyGUI.values();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
postInit();
|
||||
}
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BotanyGUI.values();
|
||||
}
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return PacketID.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
@Override
|
||||
public IProxyCore getProxy() {
|
||||
return Botany.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return PacketID.values();
|
||||
}
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "BOT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProxyCore getProxy() {
|
||||
return Botany.proxy;
|
||||
}
|
||||
@Override
|
||||
public String getModID() {
|
||||
return Constants.BOTANY_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "BOT";
|
||||
}
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "botany";
|
||||
}
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return BinnieCore.isBotanyActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onShearFlower(final PlayerInteractEvent.RightClickBlock event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShearFlower(PlayerInteractEvent event) {
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (heldItem.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onFertiliseSoil(final PlayerInteractEvent.RightClickBlock event) {
|
||||
World world = event.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (block == null || !Gardening.isSoil(block)) {
|
||||
return;
|
||||
}
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
Block block = world.getBlockState(event.getPos()).getBlock();
|
||||
if (!gardening.isSoil(block)) {
|
||||
pos = pos.down();
|
||||
block = world.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem())
|
||||
&& soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
|
||||
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
|
||||
int next = Math.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
|
||||
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next])
|
||||
&& !event.entityPlayer.capabilities.isCreativeMode) {
|
||||
ItemStack heldItem = event.entityPlayer.getHeldItem();
|
||||
heldItem.stackSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!gardening.isSoil(block)) {
|
||||
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--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
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.isAlkalineFertiliser(event.entityPlayer.getHeldItem())
|
||||
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
|
||||
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
|
||||
int next = Math.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
|
||||
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
|
||||
&& !event.entityPlayer.capabilities.isCreativeMode) {
|
||||
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
|
||||
heldItem3.stackSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
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.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.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;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void plantVanilla(BlockEvent.PlaceEvent event) {
|
||||
World world = event.world;
|
||||
int x = event.x;
|
||||
int y = event.y;
|
||||
int z = event.z;
|
||||
Block block = world.getBlock(x, y - 1, z);
|
||||
if (!(block instanceof IBlockSoil)) {
|
||||
return;
|
||||
}
|
||||
if (gardening.isWeedkiller(heldItem) && gardening.addWeedKiller(world, pos) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
|
||||
if (flower != null) {
|
||||
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void plantVanilla(final BlockEvent.PlaceEvent event) {
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos.down()).getBlock();
|
||||
|
||||
@Deprecated
|
||||
public void onPlantVanilla(PlayerInteractEvent event) {
|
||||
if (!BinnieCore.proxy.isSimulating(event.world)
|
||||
|| event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
|
||||
return;
|
||||
}
|
||||
if (!BotanyCore.getGardening().isSoil(block)) {
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = event.getPlayer();
|
||||
ItemStack heldItem = player.getHeldItem(event.getHand());
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(heldItem);
|
||||
if (flower != null) {
|
||||
flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
}
|
||||
}
|
||||
|
||||
World world = event.world;
|
||||
int x = event.x;
|
||||
int y = event.y;
|
||||
int z = event.z;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil
|
||||
&& (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) {
|
||||
py = 1;
|
||||
}
|
||||
@Deprecated
|
||||
public void onPlantVanilla(final 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;
|
||||
}
|
||||
|
||||
if (py < 0) {
|
||||
return;
|
||||
}
|
||||
if (!heldItem.isEmpty()) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
|
||||
py = 1;
|
||||
}
|
||||
if (py >= 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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--;
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onBonemeal(final BonemealEvent event) {
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = event.getBlock().getBlock();
|
||||
if (BotanyCore.getGardening().isSoil(block)) {
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
if (soil.fertilise(event.getWorld(), pos, EnumSoilType.LOAM)) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
TileEntity tile = event.getWorld().getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBonemeal(BonemealEvent event) {
|
||||
Block block = event.world.getBlock(event.x, event.y, event.z);
|
||||
if (Gardening.isSoil(block)) {
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
super(Botany.instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,40 +2,40 @@ package binnie.botany;
|
||||
|
||||
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;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CreativeTabBotany extends CreativeTabs {
|
||||
public static CreativeTabs instance = new CreativeTabBotany();
|
||||
|
||||
public static CreativeTabs instance = new CreativeTabBotany();
|
||||
public CreativeTabBotany() {
|
||||
super("Botany");
|
||||
}
|
||||
|
||||
public CreativeTabBotany() {
|
||||
super("Botany");
|
||||
}
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Blocks.RED_FLOWER, 1, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Blocks.red_flower, 1, 5);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTranslatedTabLabel() {
|
||||
return this.getTabLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslatedTabLabel() {
|
||||
return getTabLabel();
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTabLabel() {
|
||||
return I18N.localise("botany.tab.botany");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTabLabel() {
|
||||
return I18N.localise("botany.tab.botany");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getTabIconItem() {
|
||||
return Item.getItemFromBlock(Blocks.yellow_flower);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getTabIconItem() {
|
||||
return new ItemStack(Blocks.YELLOW_FLOWER);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,33 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumAcidity {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
ACID,
|
||||
NEUTRAL,
|
||||
ALKALINE;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
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 this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName(boolean withColor) {
|
||||
String localisedName = I18n.translateToLocal("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;
|
||||
@@ -10,38 +12,37 @@ import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public enum EnumFlowerChromosome implements IChromosomeType {
|
||||
SPECIES(IAlleleFlowerSpecies.class),
|
||||
PRIMARY(IAlleleInteger.class),
|
||||
SECONDARY(IAlleleInteger.class),
|
||||
FERTILITY(IAlleleInteger.class),
|
||||
TERRITORY(IAlleleArea.class),
|
||||
EFFECT(IAlleleFlowerEffect.class),
|
||||
LIFESPAN(IAlleleInteger.class),
|
||||
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
|
||||
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
|
||||
PH_TOLERANCE(IAlleleTolerance.class),
|
||||
SAPPINESS(IAlleleFloat.class),
|
||||
STEM(IAlleleInteger.class);
|
||||
|
||||
SPECIES(IAlleleFlowerSpecies.class),
|
||||
PRIMARY(IAlleleInteger.class),
|
||||
SECONDARY(IAlleleInteger.class),
|
||||
FERTILITY(IAlleleInteger.class),
|
||||
TERRITORY(IAlleleArea.class),
|
||||
EFFECT(IAlleleFlowerEffect.class),
|
||||
LIFESPAN(IAlleleInteger.class),
|
||||
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
|
||||
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
|
||||
PH_TOLERANCE(IAlleleTolerance.class),
|
||||
SAPPINESS(IAlleleFloat.class),
|
||||
STEM(IAlleleInteger.class);
|
||||
private Class<? extends IAllele> cls;
|
||||
|
||||
private Class<? extends IAllele> cls;
|
||||
EnumFlowerChromosome(final Class<? extends IAllele> cls) {
|
||||
this.cls = cls;
|
||||
}
|
||||
|
||||
EnumFlowerChromosome(Class<? extends IAllele> cls) {
|
||||
this.cls = cls;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends IAllele> getAlleleClass() {
|
||||
return this.cls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IAllele> getAlleleClass() {
|
||||
return cls;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
|
||||
}
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,31 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumFlowerStage {
|
||||
import forestry.api.genetics.ISpeciesType;
|
||||
|
||||
FLOWER("Flower"),
|
||||
SEED("Seed"),
|
||||
POLLEN("Pollen"),
|
||||
NONE("NONE");
|
||||
public enum EnumFlowerStage implements ISpeciesType {
|
||||
FLOWER("Flower"),
|
||||
SEED("Seed"),
|
||||
POLLEN("Pollen");
|
||||
|
||||
protected String name;
|
||||
public static final EnumFlowerStage[] VALUES = values();
|
||||
String name;
|
||||
|
||||
EnumFlowerStage(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
EnumFlowerStage(final 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 this.name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,33 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumMoisture {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
DRY,
|
||||
NORMAL,
|
||||
DAMP;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
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.translateToLocal("botany.moisture." + getName());
|
||||
if(withColor && color != null){
|
||||
localisedName +=color;
|
||||
}
|
||||
return localisedName;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,30 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumSoilType {
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
SOIL,
|
||||
LOAM,
|
||||
FLOWERBED;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
public enum EnumSoilType implements IStringSerializable {
|
||||
SOIL(TextFormatting.DARK_GRAY),
|
||||
LOAM(TextFormatting.GOLD),
|
||||
FLOWERBED(TextFormatting.LIGHT_PURPLE);
|
||||
|
||||
@Nullable
|
||||
final TextFormatting color;
|
||||
|
||||
EnumSoilType(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getTranslated(boolean withColor) {
|
||||
return (withColor && color != null ? color : "") + I18n.translateToLocal("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;
|
||||
}
|
||||
@@ -6,6 +6,5 @@ import forestry.api.genetics.IAlleleEffect;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public interface IAlleleFlowerEffect extends IAlleleEffect {
|
||||
|
||||
IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z);
|
||||
IEffectData doEffect(final IFlowerGenome p0, final IEffectData p1, final World p2, final int p3, final int p4, final int p5);
|
||||
}
|
||||
@@ -1,12 +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();
|
||||
|
||||
IFlowerType getType();
|
||||
EnumAcidity getPH();
|
||||
|
||||
EnumAcidity getPH();
|
||||
EnumMoisture getMoisture();
|
||||
|
||||
EnumMoisture getMoisture();
|
||||
@SideOnly(Side.CLIENT)
|
||||
int getFlowerColour(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);
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public interface IColourMix {
|
||||
IFlowerColour getColourFirst();
|
||||
|
||||
IFlowerColor getColor1();
|
||||
IFlowerColour getColourSecond();
|
||||
|
||||
IFlowerColor getColor2();
|
||||
boolean isMutation(IFlowerColour colourFirst, IFlowerColour colourSecond);
|
||||
|
||||
boolean isMutation(IFlowerColor color1, IFlowerColor color2);
|
||||
int getChance();
|
||||
|
||||
int getChance();
|
||||
|
||||
IFlowerColor getResult();
|
||||
IFlowerColour getResult();
|
||||
}
|
||||
@@ -1,35 +1,38 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
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();
|
||||
|
||||
@Override
|
||||
IFlowerGenome getGenome();
|
||||
@Nullable
|
||||
IFlowerGenome getMate();
|
||||
|
||||
IFlowerGenome getMate();
|
||||
void mate(final IFlower flower);
|
||||
|
||||
void mate(IFlower other);
|
||||
int getAge();
|
||||
|
||||
int getAge();
|
||||
void setAge(final int age);
|
||||
|
||||
void setAge(int age);
|
||||
void age();
|
||||
|
||||
void age();
|
||||
IFlower getOffspring(final World world, final BlockPos pos);
|
||||
|
||||
IFlower getOffspring(World world);
|
||||
int getMaxAge();
|
||||
|
||||
int getMaxAge();
|
||||
boolean isWilted();
|
||||
|
||||
boolean isWilted();
|
||||
void setWilted(final boolean p0);
|
||||
|
||||
void setWilted(boolean value);
|
||||
boolean hasFlowered();
|
||||
|
||||
boolean hasFlowered();
|
||||
void setFlowered(final boolean p0);
|
||||
|
||||
void setFlowered(boolean value);
|
||||
|
||||
void removeMate();
|
||||
void removeMate();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
|
||||
public interface IFlowerColor {
|
||||
|
||||
int getColor(boolean dis);
|
||||
|
||||
IAlleleInteger getAllele();
|
||||
|
||||
int getID();
|
||||
|
||||
String getName();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
|
||||
public interface IFlowerColour {
|
||||
int getColor(final boolean p0);
|
||||
|
||||
IAlleleInteger getAllele();
|
||||
|
||||
int getID();
|
||||
|
||||
String getColourName();
|
||||
}
|
||||
@@ -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 parentFlower0, IAlleleFlowerSpecies parentFlower1, IAllele[] result, int chance);
|
||||
}
|
||||
@@ -5,38 +5,37 @@ import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IGenome;
|
||||
|
||||
public interface IFlowerGenome extends IGenome {
|
||||
@Override
|
||||
IAlleleFlowerSpecies getPrimary();
|
||||
|
||||
@Override
|
||||
IAlleleFlowerSpecies getPrimary();
|
||||
@Override
|
||||
IAlleleFlowerSpecies getSecondary();
|
||||
|
||||
@Override
|
||||
IAlleleFlowerSpecies getSecondary();
|
||||
IFlowerColour getPrimaryColor();
|
||||
|
||||
IFlowerColor getPrimaryColor();
|
||||
IFlowerColour getSecondaryColor();
|
||||
|
||||
IFlowerColor getSecondaryColor();
|
||||
IFlowerColour getStemColor();
|
||||
|
||||
IFlowerColor getStemColor();
|
||||
int getFertility();
|
||||
|
||||
int getFertility();
|
||||
int getLifespan();
|
||||
|
||||
int getLifespan();
|
||||
IFlowerType getType();
|
||||
|
||||
IFlowerType getType();
|
||||
EnumTolerance getToleranceTemperature();
|
||||
|
||||
EnumTolerance getToleranceTemperature();
|
||||
EnumTolerance getToleranceMoisture();
|
||||
|
||||
EnumTolerance getToleranceMoisture();
|
||||
EnumTolerance getTolerancePH();
|
||||
|
||||
EnumTolerance getTolerancePH();
|
||||
float getAgeChance();
|
||||
|
||||
float getAgeChance();
|
||||
float getSappiness();
|
||||
|
||||
float getSappiness();
|
||||
boolean canTolerate(final EnumAcidity p0);
|
||||
|
||||
boolean canTolerate(EnumAcidity pH);
|
||||
boolean canTolerate(final EnumMoisture p0);
|
||||
|
||||
boolean canTolerate(EnumMoisture moisture);
|
||||
|
||||
boolean canTolerate(EnumTemperature temp);
|
||||
boolean canTolerate(final EnumTemperature p0);
|
||||
}
|
||||
@@ -1,10 +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 {
|
||||
@Override
|
||||
IFlowerRoot getRoot();
|
||||
|
||||
float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
|
||||
float getChance(final World world, final BlockPos pos, final IAlleleFlowerSpecies p0, final IAlleleFlowerSpecies p1, final IFlowerGenome p2, final IFlowerGenome p3);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IMutationBuilder;
|
||||
|
||||
public interface IFlowerMutationBuilder extends IMutationBuilder {
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
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 com.mojang.authlib.GameProfile;
|
||||
@@ -11,37 +14,46 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IFlowerRoot extends ISpeciesRoot {
|
||||
@Override
|
||||
@Nullable
|
||||
IFlower getMember(ItemStack memberStack);
|
||||
|
||||
@Override
|
||||
IFlower getMember(ItemStack stack);
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] template);
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] templateFirst, IAllele[] templateSecond);
|
||||
|
||||
@Override
|
||||
IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
@Override
|
||||
IFlowerGenome templateAsGenome(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IFlowerGenome templateAsGenome(IAllele[] template);
|
||||
@Override
|
||||
IFlowerGenome templateAsGenome(IAllele[] templateFrist, IAllele[] templateSecond);
|
||||
|
||||
@Override
|
||||
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
@Override
|
||||
IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile profile);
|
||||
|
||||
@Override
|
||||
IBotanistTracker getBreedingTracker(World world, GameProfile player);
|
||||
@Override
|
||||
List<? extends IFlowerMutation> getMutations(boolean shuffle);
|
||||
|
||||
@Override
|
||||
Collection<IFlowerMutation> getMutations(boolean shuffle);
|
||||
@Override
|
||||
@Nullable
|
||||
EnumFlowerStage getType(ItemStack itemStack);
|
||||
|
||||
EnumFlowerStage getStageType(ItemStack stack);
|
||||
IFlower getFlower(IFlowerGenome genome);
|
||||
|
||||
IFlower getFlower(World world, IFlowerGenome genome);
|
||||
void addConversion(ItemStack memberStack, IAllele[] template);
|
||||
|
||||
void addConversion(ItemStack stack, IAllele[] template);
|
||||
@Nullable
|
||||
IFlower getConversion(ItemStack memberStack);
|
||||
|
||||
IFlower getConversion(ItemStack stack);
|
||||
Collection<IColourMix> getColourMixes(boolean p0);
|
||||
|
||||
Collection<IColourMix> getColourMixes(boolean shuffle);
|
||||
|
||||
void registerColourMix(IColourMix colorMix);
|
||||
void registerColourMix(IColourMix colourMix);
|
||||
|
||||
boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner);
|
||||
|
||||
void tryGrowSection(World world, BlockPos pos);
|
||||
|
||||
void onGrowFromSeed(World world, BlockPos pos);
|
||||
}
|
||||
@@ -1,18 +1,25 @@
|
||||
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 {
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
IIcon getStem(EnumFlowerStage stage, boolean flowered, int section);
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
IIcon getPetalIcon(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);
|
||||
|
||||
IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section);
|
||||
@SideOnly(Side.CLIENT)
|
||||
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered);
|
||||
|
||||
int getID();
|
||||
String getName();
|
||||
|
||||
int getSections();
|
||||
int getID();
|
||||
|
||||
int ordinal();
|
||||
int getSections();
|
||||
|
||||
int ordinal();
|
||||
}
|
||||
@@ -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(final 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 ePH, EnumMoisture eMoisture, EnumTemperature eTemp);
|
||||
|
||||
boolean isWeedkiller(ItemStack heldItem);
|
||||
|
||||
boolean addWeedKiller(World world, BlockPos pos);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package binnie.botany.api.gardening;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
|
||||
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,148 +1,119 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
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 binnie.botany.Botany;
|
||||
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;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.TileUtil;
|
||||
|
||||
public class BlockCeramic extends Block implements IBlockMetadata {
|
||||
public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegister {
|
||||
public BlockCeramic() {
|
||||
super(Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setRegistryName("ceramic");
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
public BlockCeramic() {
|
||||
super(Material.rock);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setBlockName("ceramic");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
manager.registerItemModel(item, c.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@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 List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
return BlockMetadata.breakBlock(this, player, world, x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean 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 createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileCeramic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
@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);
|
||||
}
|
||||
@Override
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(new ItemStack(item, 1, c.getFlowerColorAllele().getID()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
@Override
|
||||
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.getPickBlock(state, target, world, pos, player);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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, "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());
|
||||
}
|
||||
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);
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
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 EnumFlowerColor.get(0).getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,560 +0,0 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
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 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;
|
||||
|
||||
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,48 +1,31 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
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;
|
||||
|
||||
public class BlockCeramicPatterned extends BlockDesign {
|
||||
public BlockCeramicPatterned() {
|
||||
super(CeramicDesignSystem.instance, Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("ceramicPattern");
|
||||
}
|
||||
|
||||
public BlockCeramicPatterned() {
|
||||
super(CeramicDesignSystem.instance, Material.rock);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setBlockName("ceramicPattern");
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCreativeStack(final IDesign design) {
|
||||
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.White), CeramicColor.get(EnumFlowerColor.Black), design);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCreativeStack(IDesign 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());
|
||||
}
|
||||
@Override
|
||||
public String getBlockName(final DesignBlock design) {
|
||||
return design.getDesign().getName() + " Ceramic Block";
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
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 binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockStained extends Block implements IBlockMetadata {
|
||||
|
||||
public BlockStained() {
|
||||
super(Material.glass);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setBlockName("stained");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@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,183 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
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);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("stained");
|
||||
this.setSoundType(SoundType.GLASS);
|
||||
this.setHardness(0.3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(final 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) {
|
||||
java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
|
||||
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(final World var1, final 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(final ItemStack stack, final World world, final BlockPos pos, final EnumFacing clickedBlock) {
|
||||
return TileEntityMetadata.getItemDamage(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(IBlockState state, int tileMetadata) {
|
||||
return tileMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(final ItemStack itemStack) {
|
||||
final int meta = TileEntityMetadata.getItemDamage(itemStack);
|
||||
return EnumFlowerColor.get(meta).getFlowerColorAllele().getColourName() + " " + I18N.localise("tile.botany.pigmented.glass.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, c.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;
|
||||
}
|
||||
return EnumFlowerColor.get(TileEntityMetadata.getTileMetadata(worldIn, pos)).getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -11,38 +11,41 @@ import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
|
||||
public class CeramicColor implements IDesignMaterial {
|
||||
private final static Map<EnumFlowerColor, CeramicColor> map = new LinkedHashMap<>();
|
||||
|
||||
private static Map<EnumFlowerColor, CeramicColor> map;
|
||||
static {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
CeramicColor.map.put(c, new CeramicColor(c));
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
CeramicColor.map = new LinkedHashMap<>();
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
CeramicColor.map.put(c, new CeramicColor(c));
|
||||
}
|
||||
}
|
||||
EnumFlowerColor color;
|
||||
|
||||
protected EnumFlowerColor color;
|
||||
CeramicColor(final EnumFlowerColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
CeramicColor(EnumFlowerColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
public static CeramicColor get(final EnumFlowerColor c) {
|
||||
return CeramicColor.map.get(c);
|
||||
}
|
||||
|
||||
public static CeramicColor get(EnumFlowerColor c) {
|
||||
return CeramicColor.map.get(c);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return TileEntityMetadata.getItemStack(Botany.ceramic, this.color.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal());
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack(boolean fireproof) {
|
||||
return getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return color.getName();
|
||||
}
|
||||
@Override
|
||||
public String getDesignMaterialName() {
|
||||
return this.color.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return color.getColor(false);
|
||||
}
|
||||
@Override
|
||||
public int getColour() {
|
||||
return this.color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,23 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
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.IIcon;
|
||||
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;
|
||||
@@ -20,87 +25,84 @@ import binnie.extratrees.carpentry.DesignerManager;
|
||||
import binnie.extratrees.carpentry.EnumPattern;
|
||||
|
||||
public class CeramicDesignSystem implements IDesignSystem {
|
||||
public static CeramicDesignSystem instance = new CeramicDesignSystem();
|
||||
Map<Integer, TextureAtlasSprite> primary;
|
||||
Map<Integer, TextureAtlasSprite> secondary;
|
||||
|
||||
public static CeramicDesignSystem instance = new CeramicDesignSystem();
|
||||
CeramicDesignSystem() {
|
||||
this.primary = new HashMap<>();
|
||||
this.secondary = new HashMap<>();
|
||||
DesignerManager.instance.registerDesignSystem(this);
|
||||
}
|
||||
|
||||
protected Map<Integer, IIcon> primary;
|
||||
protected Map<Integer, IIcon> secondary;
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial() {
|
||||
return CeramicColor.get(EnumFlowerColor.White);
|
||||
}
|
||||
|
||||
CeramicDesignSystem() {
|
||||
primary = new HashMap<>();
|
||||
secondary = new HashMap<>();
|
||||
DesignerManager.instance.registerDesignSystem(this);
|
||||
}
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial2() {
|
||||
return CeramicColor.get(EnumFlowerColor.Black);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial() {
|
||||
return CeramicColor.get(EnumFlowerColor.WHITE);
|
||||
}
|
||||
@Override
|
||||
public IDesignMaterial getMaterial(final int id) {
|
||||
return CeramicColor.get(EnumFlowerColor.get(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getDefaultMaterial2() {
|
||||
return CeramicColor.get(EnumFlowerColor.BLACK);
|
||||
}
|
||||
@Override
|
||||
public int getMaterialIndex(final IDesignMaterial id) {
|
||||
return ((CeramicColor) id).color.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getMaterial(int id) {
|
||||
return CeramicColor.get(EnumFlowerColor.get(id));
|
||||
}
|
||||
public String getTexturePath() {
|
||||
return "blocks/ceramic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaterialIndex(IDesignMaterial id) {
|
||||
return ((CeramicColor) id).color.ordinal();
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPrimarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return this.primary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTexturePath() {
|
||||
return "ceramic";
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSecondarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return this.secondary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getPrimaryIcon(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return primary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites() {
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
for (EnumPattern pattern : EnumPattern.values()) {
|
||||
ResourceLocation primaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0");
|
||||
ResourceLocation secondaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1");
|
||||
this.primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation));
|
||||
this.secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getSecondaryIcon(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return secondary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
for (EnumPattern pattern : EnumPattern.values()) {
|
||||
primary.put(
|
||||
pattern.ordinal(),
|
||||
BinnieCore.proxy.getIcon(
|
||||
register,
|
||||
getMod().getModID(),
|
||||
getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0"));
|
||||
secondary.put(
|
||||
pattern.ordinal(),
|
||||
BinnieCore.proxy.getIcon(
|
||||
register,
|
||||
getMod().getModID(),
|
||||
getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getAdhesive() {
|
||||
return BotanyItems.Mortar.get(1);
|
||||
}
|
||||
|
||||
public AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getAdhesive() {
|
||||
return BotanyItems.Mortar.get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getMaterial(ItemStack stack) {
|
||||
return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public IDesignMaterial getMaterial(final ItemStack itemStack) {
|
||||
return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? this.getMaterial(itemStack.getItemDamage()) : null;
|
||||
}
|
||||
}
|
||||
@@ -7,67 +7,71 @@ 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.world.World;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.ceramic.brick.CeramicBrickType;
|
||||
|
||||
public class CeramicTileRecipe implements IRecipe {
|
||||
private ItemStack cached = ItemStack.EMPTY;
|
||||
|
||||
protected ItemStack cached;
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
this.cached = this.getCraftingResult(inv);
|
||||
return !this.cached.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
cached = getCraftingResult(crafting);
|
||||
return cached != null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting inv) {
|
||||
final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
final Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
|
||||
final Item mortar = Botany.misc;
|
||||
final List<ItemStack> stacks = new ArrayList<>();
|
||||
int ix = -1;
|
||||
int iy = -1;
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
final ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty()) {
|
||||
final int x = i / 3;
|
||||
final int y = i % 3;
|
||||
if (ix == -1) {
|
||||
ix = x;
|
||||
iy = y;
|
||||
}
|
||||
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (stack.getItem() != ceramicBlock && stack.getItem() != ceramicTile && stack.getItem() != ceramicBrick && stack.getItem() != mortar) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
ItemStack result = type.getRecipe(stacks);
|
||||
if (!result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
|
||||
Item mortar = Botany.misc;
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
int ix = -1;
|
||||
int iy = -1;
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
int x = i / 3;
|
||||
int y = i % 3;
|
||||
if (ix == -1) {
|
||||
ix = x;
|
||||
iy = y;
|
||||
}
|
||||
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return this.cached;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (item != ceramicBlock && item != ceramicTile && item != ceramicBrick && item != mortar) {
|
||||
return null;
|
||||
}
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
|
||||
ItemStack stack2 = type.getRecipe(stacks);
|
||||
if (stack2 != null) {
|
||||
return stack2;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return cached;
|
||||
}
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
||||
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
|
||||
public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramic(BlockCeramic block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
return EnumFlowerColor.get(stack.getMetadata()).getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return EnumFlowerColor.get(itemStack.getItemDamage()).getFlowerColorAllele().getColourName() + " " + I18n.translateToLocal("tile.botany.ceramic.name").trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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) {
|
||||
return EnumFlowerColor.get(TileEntityMetadata.getItemDamage(stack)).getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -3,59 +3,54 @@ package binnie.botany.ceramic;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlower;
|
||||
|
||||
public class PigmentRecipe implements IRecipe {
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting crafting, final World world) {
|
||||
return !this.getCraftingResult(crafting).isEmpty();
|
||||
}
|
||||
|
||||
protected ItemStack cached;
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private ItemStack unknown;
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
|
||||
ItemStack stackInSlot = crafting.getStackInSlot(i);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
if (++n > 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (Binnie.GENETICS.getFlowerRoot().isMember(stackInSlot)) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
if (flower != null && flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public PigmentRecipe() {
|
||||
unknown = null;
|
||||
}
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
return getCraftingResult(crafting) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
return unknown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = null;
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
|
||||
if (crafting.getStackInSlot(i) != null) {
|
||||
if (++n > 1) {
|
||||
return null;
|
||||
}
|
||||
if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i));
|
||||
if (flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
||||
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
||||
}
|
||||
}
|
||||
@@ -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.ceramic, amount, ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
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);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setRegistryName("ceramicBrick");
|
||||
this.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;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
for (final 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.LargeBrick).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) {
|
||||
return getDefaultState().withProperty(TYPE, CeramicBrickType.get(meta >> 16 & 0xFF));
|
||||
}
|
||||
|
||||
@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) {
|
||||
int damage = stack.getItemDamage();
|
||||
ceramic.setColors(EnumFlowerColor.get(damage & 0xFF), EnumFlowerColor.get(damage >> 8 & 0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
@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 16777215;
|
||||
}
|
||||
|
||||
@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,75 @@
|
||||
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.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
|
||||
public class CeramicBrickPair {
|
||||
EnumFlowerColor colorFirst;
|
||||
EnumFlowerColor colorSecond;
|
||||
CeramicBrickType type;
|
||||
int ordinal;
|
||||
|
||||
CeramicBrickPair(final EnumFlowerColor colorFirst, final EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
this.type = type;
|
||||
this.ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair(ItemStack stack) {
|
||||
this(TileEntityMetadata.getItemDamage(stack));
|
||||
}
|
||||
|
||||
public CeramicBrickPair(int id) {
|
||||
this.colorFirst = EnumFlowerColor.get(id & 0xFF);
|
||||
this.colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
this.type = CeramicBrickType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return this.type.canDouble() && this.colorSecond != this.colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(int i) {
|
||||
return new ItemStack(Botany.ceramicBrick, i, this.ordinal());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = this.colorFirst.getFlowerColorAllele().getColourName();
|
||||
if (this.type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColourName();
|
||||
}
|
||||
return name + " " + this.type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
TextureAtlasSprite[] sprites = this.type.sprites;
|
||||
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
|
||||
return sprites[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Integer.hashCode(ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CeramicBrickPair
|
||||
&& ((CeramicBrickPair) obj).ordinal() == ordinal();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
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", "Ceramic 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 (final ItemStack stack : stacks) {
|
||||
if (this.isMortar(stack)) {
|
||||
++mortars;
|
||||
} else {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
++blocks;
|
||||
final int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else {
|
||||
if (blockColor != color) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mortars != 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new CeramicBrickPair(c, c, CeramicBrickType.Tile).getStack(3);
|
||||
}
|
||||
},
|
||||
Brick("brick", "Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
StripeBrick("brickstripe", "Striped Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
LargeBrick("bricklarge", "Large Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack3 = stacks.get(0);
|
||||
final CeramicBrickPair type3 = new CeramicBrickPair(stack3);
|
||||
if (type3.type == CeramicBrickType.VerticalLargeBrick) {
|
||||
type3.type = this;
|
||||
return type3.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
if (stacks.size() != 3) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
for (final ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.Tile) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final 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.LargeBrick).getStack(3);
|
||||
}
|
||||
}
|
||||
},
|
||||
Split("split", "Split Ceramic Tile") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int altCounter = 0;
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
final int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack2);
|
||||
if (type.type != CeramicBrickType.Tile) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final 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", "Chequered Ceramic Tile") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.type != CeramicBrickType.Split) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color3 = type2.colorFirst.ordinal();
|
||||
final 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", "Mixed Ceramic Tile") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.isTwoColors()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final 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;
|
||||
}
|
||||
}
|
||||
final 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);
|
||||
}
|
||||
},
|
||||
VerticalBrick("verticalbrick", "Vertical Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalStripeBrick("verticalbrickstripe", "Vertical Striped Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalLargeBrick("verticalbricklarge", "Large Vertical Ceramic Bricks") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
};
|
||||
|
||||
public static final CeramicBrickType[] VALUES = values();
|
||||
|
||||
String id;
|
||||
String name;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
TextureAtlasSprite[] sprites;
|
||||
|
||||
CeramicBrickType(final String id, final String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static CeramicBrickType get(final 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;
|
||||
}
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.LargeBrick) {
|
||||
type.type = CeramicBrickType.VerticalLargeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.Brick) {
|
||||
type.type = CeramicBrickType.VerticalBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.StripeBrick) {
|
||||
type.type = CeramicBrickType.VerticalStripeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.VerticalBrick) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.StripeBrick) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else if (stacks.size() == 4) {
|
||||
final int[] colors = {-1, -1};
|
||||
for (int index2 = 0; index2 < stacks.size(); ++index2) {
|
||||
final ItemStack stack4 = stacks.get(index2);
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.LargeBrick) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color5 = type4.colorFirst.ordinal();
|
||||
final int color6 = type4.colorSecond.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (ceramicType == CeramicBrickType.StripeBrick) {
|
||||
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);
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isMortar(final ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.Mortar.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
@@ -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(final int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack.getItemDamage());
|
||||
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.getItemDamage()).getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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() && this.colorSecond != this.colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int i) {
|
||||
final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal());
|
||||
s.setCount(i);
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
CeramicBrickType type = CeramicBrickType.VALUES[getBlockMetadata()];
|
||||
String name = this.colorFirst.getFlowerColorAllele().getColourName();
|
||||
if (type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColourName();
|
||||
}
|
||||
return name + " " + type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return this.colorFirst.ordinal() + this.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,13 +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 final int CHANCE_INTERPOLLINATION = 20;
|
||||
|
||||
public static IFlowerRoot speciesRoot = new FlowerHelper();
|
||||
|
||||
public static IFlowerRoot getFlowerRoot() {
|
||||
return BotanyCore.speciesRoot;
|
||||
}
|
||||
public static IFlowerRoot getFlowerRoot() {
|
||||
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,28 +1,36 @@
|
||||
package binnie.botany.core;
|
||||
|
||||
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.craftgui.WindowBotanistDatabase;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public enum BotanyGUI implements IBinnieGUID {
|
||||
Database,
|
||||
DatabaseNEI;
|
||||
|
||||
Database,
|
||||
DatabaseNEI;
|
||||
|
||||
@Override
|
||||
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
|
||||
Window window = null;
|
||||
switch (this) {
|
||||
case Database:
|
||||
case DatabaseNEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return window;
|
||||
}
|
||||
@Override
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
Window window = null;
|
||||
final 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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package binnie.botany.core;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.core.resource.ResourceType;
|
||||
|
||||
public enum BotanyTexture implements IBinnieTexture {
|
||||
;
|
||||
String texture;
|
||||
ResourceType type;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
private BinnieResource resource;
|
||||
|
||||
BotanyTexture(final ResourceType base, final String texture) {
|
||||
this.texture = texture;
|
||||
this.type = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BinnieResource getTexture() {
|
||||
if (resource == null) {
|
||||
resource = Binnie.RESOURCE.getPNG(Botany.instance, this.type, this.texture);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,15 @@ package binnie.botany.core;
|
||||
import binnie.core.IInitializable;
|
||||
|
||||
public class ModuleCore implements IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void postInit() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.core;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,44 +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,25 +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,31 +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,29 +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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.renderer.RenderUtil;
|
||||
|
||||
public class ControlColourDisplay extends Control implements IControlValue<IFlowerColour>, ITooltip {
|
||||
private IFlowerColour value;
|
||||
|
||||
public ControlColourDisplay(final IWidget parent, final int x, final int y, final IFlowerColour value) {
|
||||
super(parent, x, y, 16, 16);
|
||||
this.value = value;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IFlowerColour value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawSolidRect(this.getArea(), -1);
|
||||
RenderUtil.drawSolidRect(this.getArea().inset(1), -16777216 + this.getValue().getColor(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
tooltip.add(this.value.getColourName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlColourMixBox extends ControlListBox<IColourMix> {
|
||||
private int index;
|
||||
private Type type;
|
||||
|
||||
public ControlColourMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
super(parent, x, y, width, height, 12);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IColourMix value, final int y) {
|
||||
return new ControlColourMixItem(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Resultant,
|
||||
Further,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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 ControlColourMixItem extends ControlOption<IColourMix> {
|
||||
private final ControlColourDisplay itemWidget1;
|
||||
private final ControlColourDisplay itemWidget2;
|
||||
private final ControlColourDisplay itemWidget3;
|
||||
private final ControlColourMixSymbol addSymbol;
|
||||
private final ControlColourMixSymbol arrowSymbol;
|
||||
|
||||
public ControlColourMixItem(final ControlList<IColourMix> controlList, final IColourMix option, final int y) {
|
||||
super(controlList, option, y);
|
||||
IColourMix value = this.getValue();
|
||||
this.itemWidget1 = new ControlColourDisplay(this, 4, 4, value.getColourFirst());
|
||||
this.itemWidget2 = new ControlColourDisplay(this, 44, 4, value.getColourSecond());
|
||||
this.itemWidget3 = new ControlColourDisplay(this, 104, 4, value.getResult());
|
||||
this.addSymbol = new ControlColourMixSymbol(this, 24, 4, 0, value);
|
||||
this.arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1, value);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,54 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
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.geometry.Point;
|
||||
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 {
|
||||
static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
IColourMix value;
|
||||
int type;
|
||||
|
||||
protected static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
protected static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
protected ControlColourMixSymbol(final IWidget parent, final int x, final int y, final int type, final IColourMix value) {
|
||||
super(parent, x, y, 16 + type * 16, 16);
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
protected IColourMix value;
|
||||
protected int type;
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
if (this.type == 0) {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, Point.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, Point.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
protected ControlColourMixSymbol(IWidget parent, int x, int y, int type) {
|
||||
super(parent, x, y, 16 + type * 16, 16.0f);
|
||||
this.type = type;
|
||||
value = null;
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
public void setValue(final IColourMix value) {
|
||||
this.value = value;
|
||||
this.setColour(0xffffff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (type == 0) {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.type == 1) {
|
||||
final float chance = this.value.getChance();
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
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.Point;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlColourOption extends ControlTextOption<IFlowerColour> {
|
||||
ControlColourDisplay controlBee;
|
||||
Point boxPosition;
|
||||
|
||||
public ControlColourOption(final ControlList<IFlowerColour> controlList, final IFlowerColour option, final int y) {
|
||||
super(controlList, option, option.getColourName(), y);
|
||||
this.setSize(new Point(this.getSize().x(), 20));
|
||||
this.controlBee = new ControlColourDisplay(this, 2, 2, option);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new Point(22, 0));
|
||||
this.textWidget.setSize(this.textWidget.getSize().sub(new Point(24, 0)));
|
||||
final int th = CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
|
||||
final int height = Math.max(20, th + 6);
|
||||
this.setSize(new Point(this.size().x(), height));
|
||||
this.textWidget.setSize(new Point(this.textWidget.getSize().x(), height));
|
||||
this.boxPosition = new Point(2, (height - 18) / 2);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
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;
|
||||
|
||||
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,37 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
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;
|
||||
|
||||
public class PageColourMix extends PageAbstract<IFlowerColour> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMix(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Further Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Further);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getColourFirst() == colour || mix.getColourSecond() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
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;
|
||||
|
||||
public class PageColourMixResultant extends PageAbstract<IFlowerColour> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMixResultant(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Resultant Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Resultant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getResult() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@ package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
@@ -15,152 +19,85 @@ 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.Area;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
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;
|
||||
|
||||
public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
public PageSpeciesFlowerGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
public static String tolerated(final boolean t) {
|
||||
if (t) {
|
||||
return "Tolerated";
|
||||
}
|
||||
return "Not Tolerated";
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.deleteAllChildren();
|
||||
final IAllele[] template = Binnie.GENETICS.getFlowerRoot().getTemplate(species.getUID());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
final IFlower tree = Binnie.GENETICS.getFlowerRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
final IFlowerGenome genome = tree.getGenome();
|
||||
final IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
|
||||
final int w = 144;
|
||||
final int h = 176;
|
||||
new ControlText(this, new Area(0, 4, w, 16), "Genome", TextJustification.MiddleCenter);
|
||||
final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
|
||||
final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
|
||||
final int tw = w - 8 - 12;
|
||||
final int w2 = 55;
|
||||
final int w3 = tw - 50;
|
||||
int y = 0;
|
||||
final int th = 14;
|
||||
final int th2 = 18;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Temp. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Moist. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "pH. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Fertility : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
final float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Lifespan : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), "" + String.format("%.2f", lifespan) + " days", TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Nectar : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
int x = w2;
|
||||
int tot = 0;
|
||||
for (final IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (vid.getGenome().getPrimary() == treeSpecies) {
|
||||
if (tot > 0 && tot % 3 == 0) {
|
||||
x -= 54;
|
||||
y += 18;
|
||||
}
|
||||
final ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER);
|
||||
final ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
|
||||
display.setItemStack(stack);
|
||||
++tot;
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
final int numOfLines = 1 + (tot - 1) / 3;
|
||||
new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight);
|
||||
y += th;
|
||||
contents.setSize(new Point(contents.size().x(), y));
|
||||
scrollable.setScrollableContent(contents);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -23,76 +26,72 @@ 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.geometry.Area;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.util.I18N;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
ControlListBox<EnumFlowerColor> selectionBoxColors;
|
||||
|
||||
public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) {
|
||||
super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f);
|
||||
}
|
||||
public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130);
|
||||
}
|
||||
|
||||
public static Window create(EntityPlayer player, Side side, boolean nei) {
|
||||
return new WindowBotanistDatabase(player, side, nei);
|
||||
}
|
||||
public static Window create(final EntityPlayer player, final Side side, final 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
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0));
|
||||
new PageSpeciesFlowerGenome(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.genome", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
this.createMode(FlowerMode.Colour, new FlowerColourModeWidgets());
|
||||
new PageColourMixResultant(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.resultant", 0));
|
||||
new PageColourMix(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.further", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return I18N.localise("botany.gui.database.name");
|
||||
}
|
||||
@Override
|
||||
protected String getBackgroundTextureName() {
|
||||
return "FlowerDatabase";
|
||||
}
|
||||
|
||||
enum FlowerMode implements IDatabaseMode {
|
||||
enum FlowerMode implements IDatabaseMode {
|
||||
Colour;
|
||||
|
||||
COLOR;
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.gui.database.tab." + name().toLowerCase());
|
||||
}
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class FlowerColourModeWidgets extends ModeWidgets {
|
||||
public FlowerColourModeWidgets() {
|
||||
super(FlowerMode.Colour, WindowBotanistDatabase.this);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = Arrays.stream(EnumFlowerColor.values()).map( c -> c.getFlowerColorAllele()).collect(Collectors.toList());
|
||||
this.listBox.setOptions(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,108 +1,118 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
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;
|
||||
|
||||
public class CircuitGarden extends BinnieCircuit {
|
||||
private boolean isManual;
|
||||
private GardenLogic logic;
|
||||
|
||||
private boolean isManual;
|
||||
private boolean isFertilised;
|
||||
private ItemStack icon;
|
||||
private EnumMoisture moisture;
|
||||
private EnumAcidity acidity;
|
||||
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);
|
||||
this.isManual = manual;
|
||||
this.logic = new GardenLogic(moisture, ph, this.isManual, fertilised, icon, I18N.localise(this.getUnlocalizedName()));
|
||||
StringBuilder info = new StringBuilder("Flowers (")
|
||||
.append(TextFormatting.GRAY.toString())
|
||||
.append(I18N.localise("botany.moisture"))
|
||||
.append(": ")
|
||||
.append(moisture.getLocalisedName(true));
|
||||
|
||||
public CircuitGarden(EnumMoisture moisture, EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe,
|
||||
ItemStack icon) {
|
||||
super(
|
||||
"garden." + moisture.getID()
|
||||
+ ((ph != null) ? ("." + ph.getID()) : "")
|
||||
+ (manual ? ".manual" : "")
|
||||
+ (fertilised ? ".fert" : ""),
|
||||
4,
|
||||
manual ? ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual")
|
||||
: ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"),
|
||||
recipe);
|
||||
this.moisture = moisture;
|
||||
this.icon = icon;
|
||||
isManual = manual;
|
||||
isFertilised = fertilised;
|
||||
acidity = ph;
|
||||
String info = "";
|
||||
if (ph != null) {
|
||||
info.append(TextFormatting.GRAY.toString())
|
||||
.append(", ")
|
||||
.append(I18N.localise("botany.ph"))
|
||||
.append(": ")
|
||||
.append(ph.getLocalisedName(true));
|
||||
}
|
||||
String fertilizedKey = fertilised ? "for.binnie.circuit.garden.fertilized" : "for.binnie.circuit.garden.unfertilized";
|
||||
info.append(TextFormatting.RESET.toString())
|
||||
.append(" ")
|
||||
.append(I18N.localise(fertilizedKey))
|
||||
.append(")");
|
||||
this.addTooltipString(info.toString());
|
||||
}
|
||||
|
||||
if (moisture == EnumMoisture.DRY) {
|
||||
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.dry") + 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 (moisture == EnumMoisture.DAMP) {
|
||||
info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.damp") + 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.ACID) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.RED + I18N.localise("botany.ph.acid") + EnumChatFormatting.RESET;
|
||||
}
|
||||
public CircuitGarden setManual() {
|
||||
isManual = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.NEUTRAL) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.GREEN + I18N.localise("botany.ph.neutral") + EnumChatFormatting.RESET;
|
||||
}
|
||||
@Override
|
||||
public boolean isCircuitable(Object tile) {
|
||||
return tile instanceof IFarmHousing;
|
||||
}
|
||||
|
||||
if (acidity == EnumAcidity.ALKALINE) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.AQUA + I18N.localise("botany.ph.alkaline") + EnumChatFormatting.RESET;
|
||||
}
|
||||
@Nullable
|
||||
private IFarmHousing getCircuitable(Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return null;
|
||||
}
|
||||
return (IFarmHousing) tile;
|
||||
}
|
||||
|
||||
if (info.length() > 0) {
|
||||
info = " (" + info + EnumChatFormatting.RESET + ")";
|
||||
}
|
||||
addTooltipString(I18N.localise("botany.circuit.flowers") + info);
|
||||
}
|
||||
@Override
|
||||
public void onInsertion(int slot, Object tile) {
|
||||
IFarmHousing housing = getCircuitable(tile);
|
||||
if (housing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircuitable(Object tile) {
|
||||
return tile instanceof IFarmHousing;
|
||||
}
|
||||
logic.setManual(isManual);
|
||||
|
||||
@Override
|
||||
public void onInsertion(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
housing.setFarmLogic(FarmDirection.values()[slot], logic);
|
||||
}
|
||||
|
||||
GardenLogic logic = new GardenLogic((IFarmHousing) tile);
|
||||
logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName()));
|
||||
((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic);
|
||||
}
|
||||
@Override
|
||||
public void onLoad(int slot, Object tile) {
|
||||
onInsertion(slot, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(int slot, Object tile) {
|
||||
onInsertion(slot, tile);
|
||||
}
|
||||
@Override
|
||||
public void onRemoval(int slot, Object tile) {
|
||||
IFarmHousing farmHousing = getCircuitable(tile);
|
||||
if (farmHousing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoval(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]);
|
||||
}
|
||||
farmHousing.resetFarmLogic(FarmDirection.values()[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int arg0, Object arg1) {
|
||||
// ignored
|
||||
}
|
||||
@Override
|
||||
public void onTick(int slot, Object tile) {
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,49 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
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;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
boolean isManual;
|
||||
|
||||
protected World world;
|
||||
protected IFarmHousing housing;
|
||||
protected boolean isManual;
|
||||
@Override
|
||||
public IFarmLogic setManual(final boolean flag) {
|
||||
this.isManual = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FarmLogic(IFarmHousing housing) {
|
||||
this.housing = housing;
|
||||
}
|
||||
protected final boolean isAirBlock(World world, BlockPos pos) {
|
||||
return world.isAirBlock(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmLogic setManual(boolean flag) {
|
||||
isManual = flag;
|
||||
return this;
|
||||
}
|
||||
protected final IBlockState getBlockState(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
protected boolean isAirBlock(Vect position) {
|
||||
return world.isAirBlock(position.x, position.y, position.z);
|
||||
}
|
||||
protected final Block getBlock(World world, BlockPos pos) {
|
||||
return getBlockState(world, pos).getBlock();
|
||||
}
|
||||
|
||||
protected boolean isWaterBlock(Vect position) {
|
||||
return world.getBlock(position.x, position.y, position.z) == Blocks.water;
|
||||
}
|
||||
protected final int getBlockMeta(World world, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return blockState.getBlock().getMetaFromState(blockState);
|
||||
}
|
||||
|
||||
protected Block getBlock(Vect position) {
|
||||
return world.getBlock(position.x, position.y, position.z);
|
||||
}
|
||||
protected final ItemStack getAsItemStack(World world, BlockPos position) {
|
||||
return new ItemStack(getBlock(world, position), 1, getBlockMeta(world, position));
|
||||
}
|
||||
|
||||
protected int getBlockMeta(Vect position) {
|
||||
return world.getBlockMetadata(position.x, position.y, position.z);
|
||||
}
|
||||
protected final boolean isWaterBlock(World world, BlockPos pos) {
|
||||
return getBlock(world, pos) == Blocks.WATER;
|
||||
}
|
||||
|
||||
protected ItemStack getAsItemStack(Vect position) {
|
||||
return new ItemStack(getBlock(position), 1, getBlockMeta(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 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, final Block block, final int meta) {
|
||||
world.setBlockState(pos, block.getStateFromMeta(meta), 2);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,67 @@
|
||||
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 binnie.botany.flower.TileEntityFlower;
|
||||
|
||||
public class FarmableFlower implements IFarmable {
|
||||
@Override
|
||||
public boolean isSaplingAt(final World world, final BlockPos pos) {
|
||||
return world.getBlockState(pos) == Botany.flower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, int x, int y, int z) {
|
||||
return world.getBlock(x, y, z) == Botany.flower;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
IFlower flower = null;
|
||||
if (world.getTileEntity(pos) instanceof TileEntityFlower) {
|
||||
flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack);
|
||||
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
|
||||
}
|
||||
@Override
|
||||
public boolean isGermling(final ItemStack itemstack) {
|
||||
final EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack);
|
||||
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isWindfall(final ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(germling);
|
||||
Gardening.plant(world, x, y, z, flower, player.getGameProfile());
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final BlockPos pos) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getMember(germling);
|
||||
flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,23 @@ package binnie.botany.farm;
|
||||
|
||||
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;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
|
||||
public class FarmableVanillaFlower extends FarmableFlower {
|
||||
@Override
|
||||
public boolean isGermling(final ItemStack itemstack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getConversion(germling);
|
||||
return Gardening.plant(world, x, y, z, flower, player.getGameProfile());
|
||||
}
|
||||
@Override
|
||||
public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final 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.Arrays;
|
||||
|
||||
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) {
|
||||
Arrays.stream(drops).forEach(drop -> this.drops.add(drop));
|
||||
position = pos;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NonNullList<ItemStack> harvest() {
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPosition() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
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;
|
||||
@@ -11,392 +15,354 @@ 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 com.mojang.authlib.GameProfile;
|
||||
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.gardening.IBlockSoil;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.access.IOwnable;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import binnie.core.liquid.ManagerLiquid;
|
||||
|
||||
public class GardenLogic extends FarmLogic {
|
||||
List<IFarmable> farmables;
|
||||
private EnumMoisture moisture;
|
||||
@Nullable
|
||||
private EnumAcidity acidity;
|
||||
private boolean fertilised;
|
||||
private String name;
|
||||
private NonNullList<ItemStack> produce;
|
||||
private ItemStack icon;
|
||||
|
||||
protected EnumMoisture moisture;
|
||||
protected EnumAcidity acidity;
|
||||
protected boolean fertilised;
|
||||
protected String name;
|
||||
protected ArrayList<ItemStack> produce;
|
||||
protected List<IFarmable> farmables;
|
||||
public GardenLogic(EnumMoisture moisture2, @Nullable EnumAcidity acidity2, boolean isManual, boolean isFertilised, ItemStack icon2, String name2) {
|
||||
this.produce = NonNullList.create();
|
||||
(this.farmables = new ArrayList<>()).add(new FarmableFlower());
|
||||
this.farmables.add(new FarmableVanillaFlower());
|
||||
this.moisture = moisture2;
|
||||
this.acidity = acidity2;
|
||||
this.isManual = isManual;
|
||||
this.fertilised = isFertilised;
|
||||
this.icon = icon2;
|
||||
this.name = name2;
|
||||
}
|
||||
|
||||
private ItemStack icon;
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return this.fertilised ? 8 : 2;
|
||||
}
|
||||
|
||||
public GardenLogic(IFarmHousing housing) {
|
||||
super(housing);
|
||||
produce = new ArrayList<>();
|
||||
farmables = new ArrayList<>();
|
||||
farmables.add(new FarmableFlower());
|
||||
farmables.add(new FarmableVanillaFlower());
|
||||
}
|
||||
@Override
|
||||
public int getWaterConsumption(final float hydrationModifier) {
|
||||
return (int) (this.moisture.ordinal() * 40 * hydrationModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return fertilised ? 8 : 2;
|
||||
}
|
||||
@Override
|
||||
public boolean isAcceptedResource(final 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 int getWaterConsumption(float hydrationModifier) {
|
||||
return (int) (moisture.ordinal() * 40 * hydrationModifier);
|
||||
}
|
||||
@Override
|
||||
public NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
|
||||
final NonNullList<ItemStack> products = this.produce;
|
||||
this.produce = NonNullList.create();
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedResource(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
return Gardening.isSoil(item) || item == Item.getItemFromBlock(Blocks.sand)
|
||||
|| item == Item.getItemFromBlock(Blocks.dirt)
|
||||
|| Gardening.isAcidFertiliser(stack)
|
||||
|| Gardening.isAlkalineFertiliser(stack);
|
||||
}
|
||||
@Override
|
||||
public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
return this.maintainSoil(world, pos, direction, extent, farmHousing) ||
|
||||
(!this.isManual && this.maintainWater(world, pos, direction, extent, farmHousing)) ||
|
||||
this.maintainCrops(world, pos.up(), direction, extent, farmHousing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> collect() {
|
||||
Collection<ItemStack> products = produce;
|
||||
produce = new ArrayList<>();
|
||||
return products;
|
||||
}
|
||||
private boolean isWaste(final ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(Blocks.DIRT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
world = housing.getWorld();
|
||||
return maintainSoil(x, y, z, direction, extent) || !isManual && maintainWater(x, y, z, direction, extent)
|
||||
|| maintainCrops(x, y + 1, z, direction, extent);
|
||||
}
|
||||
private boolean maintainSoil(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.fertilised && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
if (soil.fertilise(world, position, EnumSoilType.FLOWERBED)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (getBlock(world, position.up()) == Botany.plant) {
|
||||
world.setBlockToAir(position.up());
|
||||
} else {
|
||||
if (this.acidity != null && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
EnumAcidity pH = soil.getPH(world, position);
|
||||
if (pH.ordinal() < this.acidity.ordinal()) {
|
||||
ItemStack stack = this.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() > this.acidity.ordinal()) {
|
||||
final ItemStack stack = this.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 (!this.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack block = this.getAsItemStack(world, position);
|
||||
ItemStack loam = this.getAvailableLoam(housing);
|
||||
if (this.isWaste(block) && !loam.isEmpty()) {
|
||||
this.produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0));
|
||||
this.setBlock(world, position, Blocks.AIR, 0);
|
||||
return trySetSoil(world, position, loam, housing);
|
||||
}
|
||||
} else if (!this.isManual) {
|
||||
if (!this.isWaterBlock(world, position)) {
|
||||
if (i % 2 == 0) {
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
FarmDirection cclock = FarmDirection.EAST;
|
||||
if (direction == FarmDirection.EAST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
} else if (direction == FarmDirection.SOUTH) {
|
||||
cclock = FarmDirection.EAST;
|
||||
} else if (direction == FarmDirection.WEST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
}
|
||||
BlockPos previous = position.offset(cclock.getFacing());
|
||||
final ItemStack soil2 = this.getAsItemStack(world, previous);
|
||||
if (!gardening.isSoil(soil2.getItem())) {
|
||||
this.trySetSoil(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isWaste(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(Blocks.dirt);
|
||||
}
|
||||
private boolean maintainWater(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
if (!this.isWaterBlock(world, position)) {
|
||||
boolean isEnclosed = true;
|
||||
if (world.isAirBlock(position.east())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.west())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.south())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.north())) {
|
||||
isEnclosed = false;
|
||||
}
|
||||
isEnclosed = (isEnclosed || this.moisture != EnumMoisture.DAMP);
|
||||
if (isEnclosed) {
|
||||
return this.trySetWater(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
Vect position = translateWithOffset(x, y, z, direction, i);
|
||||
boolean isSoil = Gardening.isSoil(world.getBlock(position.x, position.y, position.z));
|
||||
private ItemStack getAvailableLoam(IFarmHousing housing) {
|
||||
EnumMoisture[] moistures;
|
||||
if (this.moisture == EnumMoisture.DAMP) {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY};
|
||||
} else if (this.moisture == EnumMoisture.DRY) {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY};
|
||||
} else {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP};
|
||||
}
|
||||
final EnumAcidity[] acidities = {EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE};
|
||||
for (final EnumMoisture moist : moistures) {
|
||||
for (final EnumAcidity acid : acidities) {
|
||||
for (final Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) {
|
||||
final int meta = acid.ordinal() * 3 + moist.ordinal();
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
ItemStack resourceStack = new ItemStack(type, 1, meta);
|
||||
resources.add(resourceStack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return resourceStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final 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 ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// remove unnecessary blocks
|
||||
if (!isManual && !isSoil && !isAirBlock(position)) {
|
||||
Block block = world.getBlock(position.x, position.y, position.z);
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
if (block != Blocks.water) {
|
||||
dropBlockAsProduction(position);
|
||||
}
|
||||
} else if (moisture == EnumMoisture.DRY) {
|
||||
if (block != Blocks.sand) {
|
||||
dropBlockAsProduction(position);
|
||||
}
|
||||
} else {
|
||||
dropBlockAsProduction(position);
|
||||
}
|
||||
}
|
||||
private boolean trySetSoil(World world, BlockPos position, IFarmHousing housing) {
|
||||
return this.trySetSoil(world, position, this.getAvailableLoam(housing), housing);
|
||||
}
|
||||
|
||||
if (fertilised && isSoil) {
|
||||
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
|
||||
if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
private boolean trySetSoil(World world, BlockPos position, ItemStack loam, IFarmHousing housing) {
|
||||
ItemStack copy = loam;
|
||||
if (!loam.isEmpty()) {
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
|
||||
loam = new ItemStack(Botany.soil, 1, 4);
|
||||
}
|
||||
setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage());
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(copy);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) {
|
||||
world.setBlockToAir(position.x, position.y + 1, position.z);
|
||||
continue;
|
||||
}
|
||||
private boolean trySetWater(World world, BlockPos position, IFarmHousing housing) {
|
||||
final FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000);
|
||||
if (this.moisture == EnumMoisture.DAMP) {
|
||||
if (water == null || !housing.hasLiquid(water)) {
|
||||
return false;
|
||||
}
|
||||
this.setBlock(world, position, Blocks.WATER, 0);
|
||||
housing.removeLiquid(water);
|
||||
return true;
|
||||
} else {
|
||||
if (this.moisture != EnumMoisture.DRY) {
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
final ItemStack sand = new ItemStack(Blocks.SAND, 1);
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(sand);
|
||||
if (!housing.getFarmInventory().hasResources(resources)) {
|
||||
return false;
|
||||
}
|
||||
this.setBlock(world, position, Blocks.SAND, 0);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (acidity != null && isSoil) {
|
||||
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
|
||||
EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z);
|
||||
if (pH.ordinal() < acidity.ordinal()) {
|
||||
ItemStack stack = getAvailableAlkaline();
|
||||
if (stack != null && soil
|
||||
.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() + 1])) {
|
||||
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
public void setIcon(final ItemStack icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
if (pH.ordinal() > acidity.ordinal()) {
|
||||
ItemStack stack = getAvailableAcid();
|
||||
if (stack != null && soil
|
||||
.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() - 1])) {
|
||||
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isAcceptedGermling(final ItemStack itemstack) {
|
||||
for (final IFarmable farmable : this.farmables) {
|
||||
if (farmable.isGermling(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isAirBlock(position) && !world.getBlock(position.x, position.y, position.z)
|
||||
.isReplaceable(world, position.x, position.y, position.z)) {
|
||||
ItemStack block = getAsItemStack(position);
|
||||
ItemStack loam = getAvailableLoam();
|
||||
if (isWaste(block) && loam != null) {
|
||||
produce.addAll(
|
||||
Blocks.dirt.getDrops(world, position.x, position.y, position.z, block.getItemDamage(), 0));
|
||||
setBlock(position, Blocks.air, 0);
|
||||
return trySetSoil(position, loam);
|
||||
}
|
||||
} else if (!isManual) {
|
||||
if (!isWaterBlock(position)) {
|
||||
if (i % 2 == 0) {
|
||||
return trySetSoil(position);
|
||||
}
|
||||
@Override
|
||||
public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
|
||||
if (isManual) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up())))
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
FarmDirection cclock = FarmDirection.EAST;
|
||||
if (direction == FarmDirection.EAST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
} else if (direction == FarmDirection.SOUTH) {
|
||||
cclock = FarmDirection.EAST;
|
||||
} else if (direction == FarmDirection.WEST) {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getTextureMap() {
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
|
||||
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
|
||||
ItemStack soil2 = getAsItemStack(previous);
|
||||
if (!Gardening.isSoil(soil2.getItem())) {
|
||||
trySetSoil(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
Vect position = translateWithOffset(x, y, z, direction, i);
|
||||
if (!isAirBlock(position)
|
||||
&& !world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
|
||||
continue;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
if (isWaterBlock(position)) {
|
||||
continue;
|
||||
}
|
||||
protected boolean maintainCrops(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack below = this.getAsItemStack(world, position.down());
|
||||
if (gardening.isSoil(below.getItem())) {
|
||||
return trySetCrop(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isEnclosed = true;
|
||||
if (world.isAirBlock(position.x + 1, position.y, position.z)) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x - 1, position.y, position.z)) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x, position.y, position.z + 1)) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.x, position.y, position.z - 1)) {
|
||||
isEnclosed = false;
|
||||
}
|
||||
private boolean trySetCrop(World world, BlockPos position, IFarmHousing housing) {
|
||||
for (IFarmable farmable : this.farmables) {
|
||||
if (housing.plantGermling(farmable, world, position)) {
|
||||
if (housing instanceof IOwnedTile) {
|
||||
TileEntity tile = world.getTileEntity(position);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
IOwnedTile owned = (IOwnedTile) housing;
|
||||
|
||||
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
|
||||
if (isEnclosed) {
|
||||
return trySetWater(position);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
flower.setOwner(owned.getOwnerHandler().getOwner());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ItemStack getAvailableLoam() {
|
||||
EnumMoisture[] moistures;
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
moistures = new EnumMoisture[] { EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY };
|
||||
} else if (moisture == EnumMoisture.DRY) {
|
||||
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY };
|
||||
} else {
|
||||
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP };
|
||||
}
|
||||
public ItemStack getAvailableAcid(IFarmHousing housing) {
|
||||
for (final ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
EnumAcidity[] acidities = { 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 }) {
|
||||
int meta = acid.ordinal() * 3 + moist.ordinal();
|
||||
ItemStack[] resource = { new ItemStack(type, 1, meta) };
|
||||
if (housing.getFarmInventory().hasResources(resource)) {
|
||||
return resource[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (housing.getFarmInventory().hasResources(new ItemStack[] { new ItemStack(Blocks.dirt) })) {
|
||||
return new ItemStack(Blocks.dirt);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean trySetSoil(Vect position) {
|
||||
return trySetSoil(position, getAvailableLoam());
|
||||
}
|
||||
|
||||
private boolean trySetSoil(Vect position, ItemStack loam) {
|
||||
ItemStack copy = loam;
|
||||
if (loam == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
|
||||
loam = new ItemStack(Botany.soil, 0, 4);
|
||||
}
|
||||
|
||||
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
|
||||
housing.getFarmInventory().removeResources(new ItemStack[] { copy });
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean trySetWater(Vect position) {
|
||||
FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
if (!housing.hasLiquid(water)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setBlock(position, Blocks.water, 0);
|
||||
housing.removeLiquid(water);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (moisture != EnumMoisture.DRY) {
|
||||
return trySetSoil(position);
|
||||
}
|
||||
|
||||
ItemStack[] sand = { new ItemStack(Blocks.sand, 1) };
|
||||
if (!housing.getFarmInventory().hasResources(sand)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setBlock(position, Blocks.sand, 0);
|
||||
housing.getFarmInventory().removeResources(sand);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dropBlockAsProduction(Vect position) {
|
||||
ItemStack stack = new ItemStack(world.getBlock(position.x, position.y, position.z));
|
||||
if (stack.getItem() == null) {
|
||||
return;
|
||||
}
|
||||
produce.add(stack);
|
||||
world.setBlockToAir(position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedGermling(ItemStack stack) {
|
||||
for (IFarmable farmable : farmables) {
|
||||
if (farmable.isGermling(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
Vect position = translateWithOffset(x, y, z, direction, i);
|
||||
if (isAirBlock(position)
|
||||
|| world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) {
|
||||
ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
|
||||
if (Gardening.isSoil(below.getItem())) {
|
||||
return trySetCrop(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean trySetCrop(Vect position) {
|
||||
for (IFarmable farmable : farmables) {
|
||||
boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z);
|
||||
if (!success || !(housing instanceof IOwnable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z);
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
IOwnable housing2 = (IOwnable) housing;
|
||||
GameProfile prof = (GameProfile) IOwnable.class.getMethod("getOwnerProfile", new Class[0])
|
||||
.invoke(housing2);
|
||||
((TileEntityFlower) tile).setOwner(prof);
|
||||
} catch (Exception ex) {
|
||||
// ignored
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAcid() {
|
||||
for (ItemStack stack : Gardening.getAcidFertilisers()) {
|
||||
if (stack != null && stack.getItem() != null
|
||||
&& housing.getFarmInventory().hasResources(new ItemStack[] { stack })) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAlkaline() {
|
||||
for (ItemStack stack : Gardening.getAlkalineFertilisers()) {
|
||||
if (stack != null && stack.getItem() != null
|
||||
&& housing.getFarmInventory().hasResources(new ItemStack[] { stack })) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setData(EnumMoisture moisture, EnumAcidity acidity, boolean isManual, boolean fertilised,
|
||||
ItemStack icon, String name) {
|
||||
this.moisture = moisture;
|
||||
this.acidity = acidity;
|
||||
this.isManual = isManual;
|
||||
this.fertilised = fertilised;
|
||||
this.icon = icon;
|
||||
this.name = name;
|
||||
}
|
||||
public ItemStack getAvailableAlkaline(IFarmHousing housing) {
|
||||
for (final ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
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,229 +1,313 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
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 com.mojang.authlib.GameProfile;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockFlower extends BlockContainer {
|
||||
|
||||
public BlockFlower() {
|
||||
super(Material.plants);
|
||||
float f = 0.2f;
|
||||
setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, f * 3.0f, 0.5f + f);
|
||||
setTickRandomly(true);
|
||||
setBlockName("flower");
|
||||
setStepSound(Block.soundTypeGrass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return "botany.flower";
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int meta, int side) {
|
||||
return Blocks.yellow_flower.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
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);
|
||||
/* PROPERTYS */
|
||||
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);
|
||||
final float f = 0.2f;
|
||||
this.setTickRandomly(true);
|
||||
this.setRegistryName("flower");
|
||||
this.setSoundType(SoundType.PLANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
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()) {
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower tileFlower = (TileEntityFlower) tile;
|
||||
IFlower flower = tileFlower.getFlower();
|
||||
if (flower != null) {
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
final TileEntity flower = world.getTileEntity(pos);
|
||||
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
final IFlower f = flowerRoot.getMember(stack);
|
||||
if (f != null) {
|
||||
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
final TileEntity below = world.getTileEntity(pos.down());
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
if (below instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
|
||||
} else {
|
||||
final 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();
|
||||
} else {
|
||||
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 this.canPlaceBlockOn(downState.getBlock());
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(final 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) {
|
||||
this.checkAndDropBlock(worldIn, pos);
|
||||
final TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
final 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) {
|
||||
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
final TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) tile).randomUpdate(rand);
|
||||
this.checkAndDropBlock(world, pos);
|
||||
return;
|
||||
}
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(final World world, final BlockPos pos) {
|
||||
if (!this.canBlockStay(world, pos)) {
|
||||
this.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) {
|
||||
final List<ItemStack> drops = this.getDrops(world, pos, world.getBlockState(pos), 0);
|
||||
final boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (final ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
enum EnumTubeInsulate {
|
||||
Clay(0xa1aacc, "Clay"),
|
||||
Cobble(0x7b7b7b, "Cobblestone"),
|
||||
Sand(0xefeab5, "Sand"),
|
||||
HardenedClay(0x935c43, "Hardened Clay"),
|
||||
Stone(0x6d6d6d, "Smooth Stone"),
|
||||
Sandstone(0xc1b989, "Sandstone");
|
||||
|
||||
int color;
|
||||
String name;
|
||||
|
||||
EnumTubeInsulate(final int color, final String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static EnumTubeInsulate get(final int i) {
|
||||
return values()[i / 128 % values().length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.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);
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
enum EnumTubeMaterial {
|
||||
Copper(0xe3b78e, "Copper"),
|
||||
Tin(0xe1eef4, "Tin"),
|
||||
Bronze(0xddc276, "Bronze"),
|
||||
Iron(0xd8d8d8, "Iron");
|
||||
|
||||
int color;
|
||||
String name;
|
||||
|
||||
EnumTubeMaterial(final int color, final String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static EnumTubeMaterial get(final int i) {
|
||||
return values()[i % values().length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.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) {
|
||||
this.sections = type.getSections();
|
||||
this.stem = new BinnieSprite[sections];
|
||||
this.petal = new BinnieSprite[sections];
|
||||
this.variant = new BinnieSprite[sections];
|
||||
this.unflowered = new BinnieSprite[sections];
|
||||
for (int section = 0; section < sections; ++section) {
|
||||
final String suf = (section == 0) ? "" : ("" + (section + 1));
|
||||
final String pre = (sections == 1) ? "" : "double/";
|
||||
this.stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0");
|
||||
this.petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1");
|
||||
this.variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2");
|
||||
this.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 % this.sections] : this.unflowered[section % this.sections]).getSprite();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered) {
|
||||
return flowered ? variant[section % this.sections].getSprite() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,306 +1,254 @@
|
||||
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.client.renderer.texture.IIconRegister;
|
||||
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.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
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.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
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;
|
||||
|
||||
public abstract class ItemBotany extends Item {
|
||||
public class ItemBotany extends Item implements IColoredItem, IItemModelRegister {
|
||||
private EnumFlowerStage type;
|
||||
private String tag;
|
||||
|
||||
public ItemBotany(String name) {
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName(name);
|
||||
hasSubtypes = true;
|
||||
}
|
||||
public ItemBotany(final String name, EnumFlowerStage type, String tag) {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
this.hasSubtypes = true;
|
||||
this.type = type;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasEffect(final ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
final IIndividual individual = this.getIndividual(itemstack);
|
||||
return individual != null && individual.hasEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> list, final boolean flag) {
|
||||
if (!itemStack.hasTagCompound()) {
|
||||
return;
|
||||
}
|
||||
IFlower individual = (IFlower) this.getIndividual(itemStack);
|
||||
if (individual == null) {
|
||||
list.add(TextFormatting.DARK_RED + I18N.localise("botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
//Colors
|
||||
String primaryColor = genome.getPrimaryColor().getColourName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColourName();
|
||||
String stemColor = genome.getStemColor().getColourName();
|
||||
String colorInfo;
|
||||
if (!primaryColor.equals(secondaryColor)) {
|
||||
colorInfo = I18N.localise("botany.grammar.flower.secondary");
|
||||
} else {
|
||||
colorInfo = I18N.localise("botany.grammar.flower");
|
||||
}
|
||||
list.add(TextFormatting.YELLOW + colorInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
|
||||
IIndividual individual = getIndividual(stack);
|
||||
return individual != null && individual.getGenome() != null && individual.hasEffect();
|
||||
}
|
||||
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") + ">");
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
@Nullable
|
||||
protected IIndividual getIndividual(final ItemStack itemstack) {
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
if (tagCompound == null) {
|
||||
return null;
|
||||
}
|
||||
return new Flower(tagCompound);
|
||||
}
|
||||
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
IFlowerColor primaryColor = genome.getPrimaryColor();
|
||||
IFlowerColor secondColor = genome.getSecondaryColor();
|
||||
IFlowerColor stemColor = genome.getStemColor();
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
|
||||
final IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
if (tree == null) {
|
||||
return (IAlleleFlowerSpecies) BotanyCore.getFlowerRoot().getDefaultTemplate()[EnumFlowerChromosome.SPECIES.ordinal()];
|
||||
}
|
||||
return tree.getGenome().getPrimary();
|
||||
}
|
||||
|
||||
if (primaryColor == secondColor) {
|
||||
tooltip.add(
|
||||
EnumChatFormatting.YELLOW + I18N
|
||||
.localise("botany.item.tooltip.flowerColor1", primaryColor.getName(), stemColor.getName()));
|
||||
} else {
|
||||
tooltip.add(
|
||||
EnumChatFormatting.YELLOW + I18N.localise(
|
||||
"botany.item.tooltip.flowerColor2",
|
||||
primaryColor.getName(),
|
||||
secondColor.getName(),
|
||||
stemColor.getName()));
|
||||
}
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
IIndividual individual = this.getIndividual(itemstack);
|
||||
if (individual != null) {
|
||||
return individual.getDisplayName() + (!tag.isEmpty() ? " " + I18N.localise("item.botany." + tag + ".name") : "");
|
||||
}
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getSubItems(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
this.addCreativeItems(itemList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister) {}
|
||||
public void addCreativeItems(final NonNullList<ItemStack> itemList, final boolean hideSecrets) {
|
||||
for (final IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
|
||||
continue;
|
||||
}
|
||||
itemList.add(BotanyCore.getFlowerRoot().getMemberStack(individual.copy(), type));
|
||||
}
|
||||
}
|
||||
|
||||
protected IIndividual getIndividual(ItemStack itemstack) {
|
||||
return new Flower(itemstack.getTagCompound());
|
||||
}
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null) {
|
||||
return 16777215;
|
||||
}
|
||||
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return I18N.localise("botany.item.tooltip.unknown");
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (IFlowerType flowerType : (List<IFlowerType>) BlockFlower.FLOWER.getAllowedValues()) {
|
||||
flowerType.registerModels(item, manager, type);
|
||||
}
|
||||
manager.registerItemModel(item, new BotanyMeshDefinition());
|
||||
}
|
||||
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
if (individual != null && individual.getGenome() != null) {
|
||||
String tag = getTag();
|
||||
if (tag == null || tag.isEmpty()) {
|
||||
return individual.getDisplayName();
|
||||
}
|
||||
return I18N.localise("botany.item.botany.name", individual.getDisplayName(), tag);
|
||||
}
|
||||
return I18N.localise("botany.item.flowerCorrupted.name");
|
||||
}
|
||||
@Override
|
||||
public 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) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
final TileEntity target = world.getTileEntity(pos);
|
||||
if (!(target instanceof IPollinatable)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
final IPollinatable pollinatable = (IPollinatable) target;
|
||||
if (!pollinatable.canMateWith(flower)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
pollinatable.mateWith(flower);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
addCreativeItems(itemList, true);
|
||||
}
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
public void addCreativeItems(List itemList, boolean hideSecrets) {
|
||||
for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) {
|
||||
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
|
||||
continue;
|
||||
}
|
||||
itemList.add(BotanyCore.speciesRoot.getMemberStack(individual.copy(), getStage().ordinal()));
|
||||
}
|
||||
}
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = this.getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
|
||||
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
|
||||
if (flower == null || flower.getGenome() == null) {
|
||||
return 0xffffff;
|
||||
}
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) {
|
||||
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
if (renderPass == 0) {
|
||||
return flower.getGenome().getStemColor().getColor(flower.isWilted());
|
||||
}
|
||||
return (renderPass == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
|
||||
: flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 3;
|
||||
}
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == Botany.flower) {
|
||||
ItemBlock.setTileEntityNBT(world, player, pos, stack);
|
||||
Botany.flower.onBlockPlacedBy(world, pos, state, player, stack);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IFlowerType type = flower.getGenome().getPrimary().getType();
|
||||
if (renderPass == 0) {
|
||||
return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1);
|
||||
}
|
||||
if (renderPass == 1) {
|
||||
return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
|
||||
}
|
||||
return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
|
||||
Block field_150939_a = Botany.flower;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == Blocks.snow_layer) {
|
||||
side = 1;
|
||||
} else if (block != Blocks.vine && block != Blocks.tallgrass
|
||||
&& block != Blocks.deadbush
|
||||
&& !block.isReplaceable(world, x, y, z)) {
|
||||
if (side == 0) {
|
||||
y--;
|
||||
} else if (side == 1) {
|
||||
y++;
|
||||
} else if (side == 2) {
|
||||
z--;
|
||||
} else if (side == 3) {
|
||||
z++;
|
||||
} else if (side == 4) {
|
||||
x--;
|
||||
} else if (side == 5) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
return world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack);
|
||||
}
|
||||
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float hitX, float hitY, float hitZ, int metadata) {
|
||||
Block block = Botany.flower;
|
||||
if (!world.setBlock(x, y, z, block, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == block) {
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 2717 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user