Compare commits

...
61 Commits
Author SHA1 Message Date
Martin Robertz 4f3c73ee98 Merge pull request #22 from Runakai1/ChaddyMergeBee
Add All Mighty Merge Master
2022-10-09 12:58:08 +02:00
Runakai1 a14ed03d5e Merge branch 'master' into ChaddyMergeBee 2022-10-09 12:57:00 +02:00
Runakai1 a80a7429b1 Add All Mighty Merge Master 2022-10-09 12:56:18 +02:00
Runakai1 8541ba8e53 Merge pull request #21 from Runakai1/ChaddyBaddyBeebee
Add kuba6000 to chad bee
2022-10-09 12:48:20 +02:00
Runakai1 3d65061055 Add kuba6000 to chad bee 2022-10-09 12:41:09 +02:00
Martin Robertz 41d1e97d7c Merge pull request #20 from Kiwi233/master-MC1.7.10
Update zh_CN.lang
2022-09-24 12:41:12 +02:00
[Kiwi233] a811e2b5e4 Update zh_CN.lang 2022-09-24 11:18:30 +08:00
Martin Robertz 4ba17bf8f3 Merge pull request #19 from Runakai1/ChadBeeLang
Updated lang file for chad bee so it finally works
2022-08-15 15:18:54 +02:00
Runakai1 0ae7dcefa3 Updated lang file for chad bee so it finally works 2022-08-15 14:50:12 +02:00
Connor-Colenso bc95495504 Merge pull request #18 from AlbertoPirillo/genetics-better-info
Genetics - Better info for Acclimatiser and Isolator
2022-08-12 22:23:46 +01:00
Alberto Pirillo 004c540346 Update Genetics Isolator's info to state that it has a chance to destroy the individual 2022-08-12 16:56:48 +02:00
Alberto Pirillo c43f1f05c5 Update Genetics Acclimatizer's info to state that it only has a chance to succeed 2022-08-11 01:42:37 +02:00
Martin Robertz 3ce7424abc Merge pull request #17 from Runakai1/bees-balance-change
Changed Format
2022-07-31 16:47:36 +07:00
Runakai1 5cafd12ce8 Changed Format
Changed Format of Names for the Chad Bee
2022-07-31 11:10:11 +02:00
Martin Robertz 9a423c4bfd Merge pull request #16 from Runakai1/bees-balance-change
bees-balance-changes in ExtraBees
2022-07-31 14:17:55 +07:00
Runakai1 e4d248b5a9 Changed Mutatron and Flowers
Added a new Bedrock Flower
Modified Mutatron Numbers based on Wiki. Also buffed some.
Uranfuel: 4->8
MOXFuel removed
Plutonium: 8->15
smallPlutonium: 5->9
Uran235: 4->10
smallUran: 2.5 -> 5.5
Nether star: 50
2022-07-30 23:15:46 +02:00
Runakai1 4520180638 added Jimbo
(he made the multiblock design) VERY BEAUTIFUL
2022-07-29 18:25:15 +02:00
Runakai1 7d14960a72 Mitch.
Mitch.
2022-07-29 18:19:15 +02:00
Runakai1 66bb31bfa8 Added one Bee
Added the Chad bee
Added RestrictedByGroup breeding requirement
2022-07-29 17:42:00 +02:00
Jason Mitchell 37bb054dd3 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:46:59 -07:00
Connor-Colenso 0c9ed04ac5 Merge pull request #15 from DianeXD/fix-genedatabase
Allow gene database to add species with the same name
2022-07-11 05:14:54 +01:00
DianeXD c641da2f7f Allow gene database to add species with the same name 2022-07-06 14:57:24 +08:00
Martin Robertz c91da9fee9 Merge pull request #13 from DianeXD/master
NEI Integration
2022-07-03 14:58:56 +07:00
DianeXD 4d67be487a Resolve conflict... 2022-07-03 12:40:52 +08:00
DianeXD 60325eeab9 Resolve conflict 2022-07-03 12:32:57 +08:00
DianeXD 8683a345c3 Update buildscript & spotlessApply 2022-07-03 12:17:51 +08:00
DianeXD e4329e2b8f Merge branch 'GTNewHorizons:master' into master 2022-07-03 12:07:41 +08:00
Connor-Colenso 2e193f2b8f Merge pull request #14 from DianeXD/Fix-worker 2022-07-03 04:38:04 +01:00
DianeXD bc4ec455e5 Fix ExtraTrees worker 2022-07-03 10:34:56 +08:00
DianeXD ba9e3ccf3e Fix tip 2022-06-30 16:38:14 +08:00
DianeXD ea417583b6 Change handler name 2022-06-29 22:52:11 +08:00
DianeXD 4ffe81967d Add NEI support for ExtraTrees 2022-06-29 22:48:09 +08:00
DianeXD 4aaa092db9 Add NEI support for Genetics 2022-06-29 20:45:17 +08:00
DianeXD 2f796f4478 Update buildscript 2022-06-29 20:28:41 +08:00
Martin Robertz 68fff7161a Merge pull request #12 from GTNewHorizons/maven
update buildscript
2022-02-13 13:13:57 +01:00
bombcar c7b8f2770a update buildscript 2022-02-12 16:02:35 -06:00
Martin Robertz 280ed91925 Merge pull request #11 from DrParadox7/patch-2
Fix Volcanic Branch Bees
2022-01-05 17:00:41 +01:00
DrParadox7 d08ebbde14 Fix Volcanic Branch Bees
Volcanic bees (from Nether hives) now natively work in the Nether.
2022-01-05 00:13:46 +00:00
Martin Robertz 51d7f51c44 Merge pull request #10 from GTNewHorizons/version
Add version information
2021-12-24 08:43:41 +01:00
bombcar b3bf9ea9ac fix proxy 2021-12-23 16:30:04 -06:00
bombcar 0b23dcdb39 add version 2021-12-23 12:43:30 -06:00
Martin Robertz 7553983e28 Merge pull request #9 from DrParadox7/patch-1
ExtraTrees' Butterfly crashing on Escritoire
2021-12-18 17:46:14 +01:00
DrParadox7 d47246adbe ExtraTrees' Butterfly crashing on Escritoire 2021-12-17 02:43:43 +00:00
Martin Robertz 91446f7c07 ignore bat file 2021-12-10 23:55:44 +01:00
Johann Bernhardt c84b8ae033 Migrated to unified build script 2021-12-09 13:56:39 +01:00
Martin Robertz a64ac3e19c Merge pull request #8 from GTNewHorizons/D-Cysteine-patch-1
Replacing jar with slightly fresher one
2021-08-14 22:48:02 +02:00
D-Cysteine a24d7a339c Replacing jar with slightly fresher one 2021-08-14 14:45:53 -06:00
Martin Robertz d92cae88e2 Merge pull request #7 from D-Cysteine/master-MC1.7.10
Update to latest Forestry API
2021-08-14 15:48:48 +02:00
D-Cysteine 7b021331bb Update to latest Forestry API 2021-08-12 20:55:36 -06:00
Martin Robertz 3a1b633044 Merge pull request #6 from TataTawa/patch-1
Update ExtraTreeSpecies.java
2020-08-04 22:23:08 +02:00
TataTawa 7b744a3e2c Update ExtraTreeSpecies.java
correct item name
2020-08-04 08:09:02 +00:00
DreamMasterXXL de53168447 bump version 2020-05-27 15:00:41 +02:00
Martin Robertz 18073d2f76 Merge pull request #4 from Kiwi233/master-MC1.7.10
Update zh_CN.lang
2020-05-27 14:07:12 +02:00
[Kiwi233] 87581cd03b Update zh_CN.lang 2020-05-25 21:52:34 +08:00
Dream-Master 6facfe5fa8 bump version 2020-03-19 18:46:56 +01:00
Martin Robertz e32e427f93 Merge pull request #3 from GTNewHorizons/wrong-blockname-in-waila
Fix Extra Trees fences and gates showing up wrong in WAILA
2020-03-18 17:05:57 +01:00
Wilhelm Schuster fe35f8e237 Fix fences and gates showing up wrong in WAILA 2020-03-18 16:26:49 +01:00
Wilhelm Schuster 4836d89ed9 Update gitignore 2020-03-18 15:20:31 +01:00
Martin Robertz d486b30dff Merge pull request #2 from GTNewHorizons/connectTo-patch
fix(fences): connection to logic
2020-03-08 19:38:15 +01:00
Léa Gris 1b9212786f bump(version): 2.0.27 2020-03-08 19:24:41 +01:00
Léa Gris d8bf61a44e fix(fences): connection to logic
Fix ExtraTrees fences to connect correctly to other wooden fences and fence gates.

Address issue: [Extra Trees fences are buggy #5694](https://github.com/GTNewHorizons/NewHorizons/issues/5694)

Works even better with https://github.com/mitchej123/Hodgepodge/pull/2 witch patches
vanilla fences to connect with other mod fences.
2020-03-08 19:18:14 +01:00
857 changed files with 55063 additions and 50309 deletions

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
RUNDIR="run"
CRASH="crash-reports"
SERVERLOG="server.log"
if [[ -d $RUNDIR/$CRASH ]]; then
echo "Crash reports detected:"
cat $RUNDIR/$CRASH/crash*.txt
exit 1
fi
if grep --quiet "Fatal errors were detected" $SERVERLOG; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" $SERVERLOG; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' $SERVERLOG; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+13
View File
@@ -0,0 +1,13 @@
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
+14
View File
@@ -0,0 +1,14 @@
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
+27 -15
View File
@@ -1,20 +1,32 @@
.gradle .gradle
# IntelliJ .settings
/build /.idea/
/run /.vscode/
/eclipse /run/
/out /build/
/classes /eclipse/
.idea .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/
*.iml *.iml
*.ipr *.ipr
*.iws *.iws
# minecraft src/main/resources/mixins.*.json
/config
/logs
/saves
/options.txt
/usernamecache.json
changelog.html
*.bat *.bat
*.DS_Store
!gradlew.bat
-24
View File
@@ -1,24 +0,0 @@
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
+3
View File
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
+1 -676
View File
@@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@@ -163,678 +163,3 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the permanent authorization for you to choose that version for the
Library. 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>.
+890 -49
View File
@@ -1,91 +1,932 @@
//version: 1656760175
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import java.nio.file.Files
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
buildscript { buildscript {
repositories { repositories {
mavenCentral()
maven { maven {
name = "forge" name 'forge'
url = "https://files.minecraftforge.net/maven" url 'https://maven.minecraftforge.net'
} }
maven { maven {
name = "sonatype" name 'sonatype'
url = "https://oss.sonatype.org/content/repositories/snapshots/" url 'https://oss.sonatype.org/content/repositories/snapshots/'
} }
maven { maven {
url "https://plugins.gradle.org/m2/" name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
maven {
name 'jitpack'
url 'https://jitpack.io'
} }
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.47"
} }
} }
plugins { plugins {
id "com.matthewprenger.cursegradle" version "1.0.6" id 'java-library'
id 'idea'
id 'eclipse'
id 'scala'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id "com.diffplug.spotless" version "6.7.2"
} }
apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
def out = services.get(StyledTextOutputFactory).create('an-output')
apply plugin: 'forge' apply plugin: 'forge'
version = "2.0.26" def projectJavaVersion = JavaLanguageVersion.of(8)
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.7.10-gtnh"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// uncomment this hack if you use old IDEA java {
/*sourceSets { toolchain {
main { languageVersion.set(projectJavaVersion)
output.resourcesDir = output.classesDir
} }
}*/ }
idea {
module {
inheritOutputDirs = true
downloadJavadoc = true
downloadSources = true
}
}
// Spotless autoformatter
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
// Can be locally toggled via spotless:off/spotless:on comments
spotless {
encoding 'UTF-8'
format 'misc', {
target '.gitignore'
trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
java {
toggleOffOn()
importOrder()
removeUnusedImports()
palantirJavaFormat('1.1.0') // last version supporting jvm 8
}
kotlin {
toggleOffOn()
ktfmt('0.39')
}
groovyGradle {
toggleOffOn()
importOrder()
target '*.gradle'
greclipse('4.19.0') // last version supporting jvm 8
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinPlugin")
checkPropertyExists("mixinsPackage")
checkPropertyExists("coreModClass")
checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
String channel = project.findProperty('channel') ? project.channel : 'stable'
String mappingsVersion = project.findProperty('mappingsVersion') ? project.mappingsVersion : '12'
String remoteMappings = project.findProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
if(accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
// Make sure GregTech build won't time out
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
}
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
try {
'git config core.fileMode false'.execute()
}
catch (Exception ignored) {
out.style(Style.Failure).println("git isn't installed at all")
}
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception ignored) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
version = minecraftVersion + '-' + identifiedVersion
ext {
modVersion = identifiedVersion
}
if(identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
}
else {
archivesBaseName = modId
}
def arguments = []
def jvmArguments = []
if (usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
if (usesMixinDebug.toBoolean()) {
jvmArguments += [
"-Dmixin.debug.countInjections=true",
"-Dmixin.debug.verbose=true",
"-Dmixin.debug.export=true"
]
}
}
minecraft { minecraft {
version = "1.7.10-10.13.4.1614-1.7.10" version = minecraftVersion + '-' + forgeVersion + '-' + minecraftVersion
runDir = "eclipse" runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
replace gradleTokenVersion, modVersion
}
if(gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
clientIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
if(developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}
serverIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
}
}
if(file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}
repositories {
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
if(usesMixins.toBoolean()) {
maven {
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
}
maven {
url 'https://jitpack.io'
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
}
}
apply from: 'dependencies.gradle'
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if (usesMixins.toBoolean()) {
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
if (!mixinConfigFile.exists()) {
mixinConfigFile.text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
"""
}
}
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
}
shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}
jar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
if(usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
if(usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
}
}
runClient {
if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}
args(arguments)
jvmArgs(jvmArguments)
}
runServer {
args(arguments)
jvmArgs(jvmArguments)
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = projectJavaVersion
}
)
} }
processResources { processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info' include 'mcmod.info'
expand 'version': project.version,
'mcversion': project.minecraft.version, // replace modVersion and minecraftVersion
'modid': "BinnieMods" expand "minecraftVersion": project.minecraft.version,
"modVersion": modVersion,
"modId": modId,
"modName": modName
} }
if(usesMixins.toBoolean()) {
from refMap
}
// copy everything else that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info' exclude 'mcmod.info'
} }
} }
task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { def getManifestAttributes() {
filePath = "changelog.html" def manifestAttributes = [:]
untaggedName = "Current release ${project.version}" if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
fromCommit = "dbc5c1a564c39e4a9c042411d1bdbe450985ce2c" manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
toRef = "HEAD" }
templateContent = file('changelog.mustache').getText('UTF-8')
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
}
if(coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
]
}
return manifestAttributes
} }
curseforge { task sourcesJar(type: Jar) {
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0' from (sourceSets.main.allSource)
project { from (file("$projectDir/LICENSE"))
id = '223525' getArchiveClassifier().set('sources')
changelog = file('changelog.html') }
changelogType = 'html'
releaseType = 'release' task shadowDevJar(type: ShadowJar) {
relations { project.configurations.shadeCompile.each { dep ->
requiredLibrary 'forestry' from(project.zipTree(dep)) {
incompatible 'binnie-fix' exclude 'META-INF', 'META-INF/**'
incompatible 'binniepatcher' }
incompatible 'more-binnie-fixes' }
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
target = tasks.shadowDevJar
prefix = modGroup + ".shadow"
}
task circularResolverJar(type: Jar) {
dependsOn(relocateShadowDevJar)
dependsOn(shadowDevJar)
enabled = false
}
task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
getArchiveClassifier().set('api')
}
artifacts {
if(!noPublishedSources) {
archives sourcesJar
}
archives devJar
if(apiPackage) {
archives apiJar
}
}
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
// and isn't strictly needed with the POM so just disable it.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// workaround variable hiding in pom processing
def projectConfigs = project.configurations
publishing {
publications {
maven(MavenPublication) {
from components.java
if(usesShadowedDependencies.toBoolean()) {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
artifact source: apiJar, classifier: "api"
}
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
def badArtifacts = [:].withDefault {[] as Set<String>}
for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) {
for (dependency in configuration.allDependencies) {
badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
}
}
// example for specifying extra stuff to ignore
// badArtifacts["org.example.group"] += "artifactName"
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
badArtifacts[it.groupId.text()].contains(it.artifactId.text())
}.each() {
it.parent().remove(it)
}
}
}
}
repositories {
maven {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
} }
} }
} }
afterEvaluate { // Updating
tasks.curseforge223525.dependsOn.add(gitChangelogTask) task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
} }
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
return versionLine.split(": ").last()
}
return ""
}
configure(updateBuildScript) {
group = 'forgegradle'
description = 'Updates the build script to the latest version'
}
// Parameter Deobfuscation
task deobfParams {
doLast {
String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion"
String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
String paramsCSV = "$mcpDir/params.csv"
download.run {
src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
dest mcpZIP
overwrite false
}
if(!file(paramsCSV).exists()) {
println("Extracting MCP archive ...")
unzip(mcpZIP, mcpDir)
}
println("Parsing params.csv ...")
Map<String, String> params = new HashMap<>()
Files.lines(Paths.get(paramsCSV)).forEach{line ->
String[] cells = line.split(",")
if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
params.put(cells[0], cells[1])
}
}
out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!")
out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.")
}
}
static int replaceParams(File file, Map<String, String> params) {
int fileCount = 0
if(file.isDirectory()) {
for(File f : file.listFiles()) {
fileCount += replaceParams(f, params)
}
return fileCount
}
println("Visiting ${file.getName()} ...")
try {
String content = new String(Files.readAllBytes(file.toPath()))
int hash = content.hashCode()
params.forEach{key, value ->
content = content.replaceAll(key, value)
}
if(hash != content.hashCode()) {
Files.write(file.toPath(), content.getBytes("UTF-8"))
return 1
}
} catch(Exception e) {
e.printStackTrace()
}
return 0
}
// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681)
static unzip(String zipFileName, String outputDir) {
byte[] buffer = new byte[16384]
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))
ZipEntry zipEntry = zis.getNextEntry()
while (zipEntry != null) {
File newFile = new File(outputDir + File.separator, zipEntry.name)
if (zipEntry.isDirectory()) {
if (!newFile.isDirectory() && !newFile.mkdirs()) {
throw new IOException("Failed to create directory $newFile")
}
} else {
// fix for Windows-created archives
File parent = newFile.parentFile
if (!parent.isDirectory() && !parent.mkdirs()) {
throw new IOException("Failed to create directory $parent")
}
// write file content
FileOutputStream fos = new FileOutputStream(newFile)
int len = 0
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len)
}
fos.close()
}
zipEntry = zis.getNextEntry()
}
zis.closeEntry()
zis.close()
}
configure(deobfParams) {
group = 'forgegradle'
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
}
// Dependency Deobfuscation
def deobf(String sourceURL) {
try {
URL url = new URL(sourceURL)
String fileName = url.getFile()
//get rid of directories:
int lastSlash = fileName.lastIndexOf("/")
if(lastSlash > 0) {
fileName = fileName.substring(lastSlash + 1)
}
//get rid of extension:
if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
fileName = fileName.substring(0, fileName.lastIndexOf("."))
}
String hostName = url.getHost()
if(hostName.startsWith("www.")) {
hostName = hostName.substring(4)
}
List parts = Arrays.asList(hostName.split("\\."))
Collections.reverse(parts)
hostName = String.join(".", parts)
return deobf(sourceURL, "$hostName/$fileName")
} catch(Exception e) {
return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
}
}
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String rawFileName) {
String bon2Version = "2.5.1"
String fileName = URLDecoder.decode(rawFileName, "UTF-8")
String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
String bon2Dir = "$cacheDir/forge_gradle/deobf"
String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
if(file(deobfFile).exists()) {
return files(deobfFile)
}
String mappingsVer
if(remoteMappings) {
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
zipMappings(mappingsZIP, remoteMappings, bon2Dir)
mappingsVer = "snapshot_$id"
} else {
mappingsVer = "${channel}_$mappingsVersion"
}
download.run {
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
dest bon2File
quiet true
overwrite false
}
download.run {
src sourceURL
dest obfFile
quiet true
overwrite false
}
exec {
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
workingDir bon2Dir
standardOutput = new FileOutputStream("${deobfFile}.log")
}
return files(deobfFile)
}
def zipMappings(String zipPath, String url, String bon2Dir) {
File zipFile = new File(zipPath)
if(zipFile.exists()) {
return
}
String fieldsCache = "$bon2Dir/data/fields.csv"
String methodsCache = "$bon2Dir/data/methods.csv"
download.run {
src "${url}fields.csv"
dest fieldsCache
quiet true
}
download.run {
src "${url}methods.csv"
dest methodsCache
quiet true
}
zipFile.getParentFile().mkdirs()
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
zos.putNextEntry(new ZipEntry("fields.csv"))
Files.copy(Paths.get(fieldsCache), zos)
zos.closeEntry()
zos.putNextEntry(new ZipEntry("methods.csv"))
Files.copy(Paths.get(methodsCache), zos)
zos.closeEntry()
zos.close()
}
// Helper methods
def checkPropertyExists(String propertyName) {
if (!project.hasProperty(propertyName)) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
+11
View File
@@ -0,0 +1,11 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:ForestryMC:4.4.6:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:cofh-lib-220333:2388748')
}
+64
View File
@@ -0,0 +1,64 @@
modName = Binnie Core
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
modId = BinnieCore
modGroup = binnie
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = BinnieCore.java
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# 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/
# Example value: mymodid_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = 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
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
customArchiveBaseName = binnie-mods
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
Vendored
+19 -3
View File
@@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or 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.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` 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. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
Vendored
+17 -1
View File
@@ -1,3 +1,19 @@
@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 @rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
+2
View File
@@ -0,0 +1,2 @@
before_install:
- ./gradlew setupCIWorkspace
Binary file not shown.
Binary file not shown.
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
// Add any additional repositories for your dependencies here
repositories {
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
name 'ic2'
url 'http://maven.ic2.player.to/'
metadataSources {
mavenPom()
artifact()
}
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
+7 -8
View File
@@ -7,16 +7,15 @@ import binnie.core.liquid.ManagerLiquid;
import binnie.core.machines.ManagerMachine; import binnie.core.machines.ManagerMachine;
import binnie.core.mod.config.ManagerConfig; import binnie.core.mod.config.ManagerConfig;
import binnie.core.resource.ManagerResource; import binnie.core.resource.ManagerResource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class Binnie { public final class Binnie {
public static List<ManagerBase> Managers = new ArrayList<>(); public static List<ManagerBase> Managers = new ArrayList<>();
public static ManagerGenetics Genetics = new ManagerGenetics(); public static ManagerGenetics Genetics = new ManagerGenetics();
public static ManagerConfig Configuration = new ManagerConfig(); public static ManagerConfig Configuration = new ManagerConfig();
public static ManagerLiquid Liquid = new ManagerLiquid(); public static ManagerLiquid Liquid = new ManagerLiquid();
public static ManagerMachine Machine = new ManagerMachine(); public static ManagerMachine Machine = new ManagerMachine();
public static ManagerItem Item = new ManagerItem(); public static ManagerItem Item = new ManagerItem();
public static ManagerResource Resource = new ManagerResource(); public static ManagerResource Resource = new ManagerResource();
} }
+261 -248
View File
@@ -53,287 +53,300 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
@Mod( @Mod(
modid = "Botany", modid = "Botany",
name = "Botany", name = "Botany",
useMetadata = true, version = BinnieCore.VERSION,
dependencies = "after:BinnieCore" useMetadata = true,
) dependencies = "after:BinnieCore")
public class Botany extends AbstractMod { public class Botany extends AbstractMod {
@Mod.Instance("Botany") @Mod.Instance("Botany")
public static Botany instance; public static Botany instance;
@SidedProxy( @SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
clientSide = "binnie.botany.proxy.ProxyClient", public static Proxy proxy;
serverSide = "binnie.botany.proxy.ProxyServer"
)
public static Proxy proxy;
public static BlockFlower flower; public static BlockFlower flower;
public static Item seed; public static Item seed;
public static Item pollen; public static Item pollen;
public static ItemDictionary database; public static ItemDictionary database;
public static BlockPlant plant; public static BlockPlant plant;
public static ItemTrowel trowelWood; public static ItemTrowel trowelWood;
public static ItemTrowel trowelStone; public static ItemTrowel trowelStone;
public static ItemTrowel trowelIron; public static ItemTrowel trowelIron;
public static ItemTrowel trowelDiamond; public static ItemTrowel trowelDiamond;
public static ItemTrowel trowelGold; public static ItemTrowel trowelGold;
public static BlockSoil soil; public static BlockSoil soil;
public static BlockSoil loam; public static BlockSoil loam;
public static BlockSoil flowerbed; public static BlockSoil flowerbed;
public static BlockSoil soilNoWeed; public static BlockSoil soilNoWeed;
public static BlockSoil loamNoWeed; public static BlockSoil loamNoWeed;
public static BlockSoil flowerbedNoWeed; public static BlockSoil flowerbedNoWeed;
public static ItemInsulatedTube insulatedTube; public static ItemInsulatedTube insulatedTube;
public static ItemSoilMeter soilMeter; public static ItemSoilMeter soilMeter;
public static ItemMisc misc; public static ItemMisc misc;
public static ItemFlower flowerItem; public static ItemFlower flowerItem;
public static ItemPigment pigment; public static ItemPigment pigment;
public static ItemClay clay; public static ItemClay clay;
public static BlockCeramic ceramic; public static BlockCeramic ceramic;
public static BlockCeramicPatterned ceramicTile; public static BlockCeramicPatterned ceramicTile;
public static BlockStained stained; public static BlockStained stained;
public static BlockCeramicBrick ceramicBrick; public static BlockCeramicBrick ceramicBrick;
public Botany() { public Botany() {
Botany.instance = this; Botany.instance = this;
} }
@Mod.EventHandler @Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
addModule(new ModuleCore()); addModule(new ModuleCore());
addModule(new ModuleGenetics()); addModule(new ModuleGenetics());
addModule(new ModuleGardening()); addModule(new ModuleGardening());
preInit(); preInit();
} }
@Mod.EventHandler @Mod.EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
init(); init();
} }
@Mod.EventHandler @Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) { public void postInit(FMLPostInitializationEvent event) {
postInit(); postInit();
} }
@Override @Override
public IBinnieGUID[] getGUIDs() { public IBinnieGUID[] getGUIDs() {
return BotanyGUI.values(); return BotanyGUI.values();
} }
@Override @Override
public Class<?>[] getConfigs() { public Class<?>[] getConfigs() {
return new Class[0]; return new Class[0];
} }
@Override @Override
public IPacketID[] getPacketIDs() { public IPacketID[] getPacketIDs() {
return PacketID.values(); return PacketID.values();
} }
@Override @Override
public IProxyCore getProxy() { public IProxyCore getProxy() {
return Botany.proxy; return Botany.proxy;
} }
@Override @Override
public String getChannel() { public String getChannel() {
return "BOT"; return "BOT";
} }
@Override @Override
public String getModID() { public String getModID() {
return "botany"; return "botany";
} }
@Override @Override
protected Class<? extends BinniePacketHandler> getPacketHandler() { protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class; return PacketHandler.class;
} }
@SubscribeEvent @SubscribeEvent
public void onShearFlower(PlayerInteractEvent event) { public void onShearFlower(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return; return;
} }
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Items.shears) { if (event.entityPlayer != null
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); && event.entityPlayer.getHeldItem() != null
if (tile instanceof TileEntityFlower) { && event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntityFlower flower = (TileEntityFlower) tile; TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
flower.onShear(); if (tile instanceof TileEntityFlower) {
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer); TileEntityFlower flower = (TileEntityFlower) tile;
} flower.onShear();
} event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Botany.pollen) { if (event.entityPlayer != null
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); && event.entityPlayer.getHeldItem() != null
if (tile instanceof TileEntityFlower) { && event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntityFlower flower = (TileEntityFlower) tile; TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem()); if (tile instanceof TileEntityFlower) {
if (pollen != null && flower.canMateWith(pollen)) { TileEntityFlower flower = (TileEntityFlower) tile;
flower.mateWith(pollen); IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (!event.entityPlayer.capabilities.isCreativeMode) { if (pollen != null && flower.canMateWith(pollen)) {
ItemStack heldItem = event.entityPlayer.getHeldItem(); flower.mateWith(pollen);
heldItem.stackSize--; if (!event.entityPlayer.capabilities.isCreativeMode) {
} ItemStack heldItem = event.entityPlayer.getHeldItem();
} heldItem.stackSize--;
} }
} }
} }
}
}
@SubscribeEvent @SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent event) { public void onFertiliseSoil(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) { if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
return; return;
} }
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) { if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return; return;
} }
int y = event.y; int y = event.y;
Block block = event.world.getBlock(event.x, y, event.z); Block block = event.world.getBlock(event.x, y, event.z);
if (block == null || !Gardening.isSoil(block)) { if (block == null || !Gardening.isSoil(block)) {
block = event.world.getBlock(event.x, --y, event.z); block = event.world.getBlock(event.x, --y, event.z);
} }
if (block == null || !Gardening.isSoil(block)) { if (block == null || !Gardening.isSoil(block)) {
return; return;
} }
IBlockSoil soil = (IBlockSoil) block; IBlockSoil soil = (IBlockSoil) block;
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem()) && soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) { if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem())
EnumSoilType type = soil.getType(event.world, event.x, y, event.z); && soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
int next = Math.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2); EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) { int next = Math.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
ItemStack heldItem = event.entityPlayer.getHeldItem(); if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next])
heldItem.stackSize--; && !event.entityPlayer.capabilities.isCreativeMode) {
return; ItemStack heldItem = event.entityPlayer.getHeldItem();
} heldItem.stackSize--;
} return;
}
}
if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem()) && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) { if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem())
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z); && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) {
int next = Math.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0); EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) { int next = Math.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
ItemStack heldItem2 = event.entityPlayer.getHeldItem(); if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
heldItem2.stackSize--; && !event.entityPlayer.capabilities.isCreativeMode) {
return; ItemStack heldItem2 = event.entityPlayer.getHeldItem();
} heldItem2.stackSize--;
} return;
}
}
if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem()) && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) { if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem())
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z); && soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
int next = Math.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2); EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next]) && !event.entityPlayer.capabilities.isCreativeMode) { int next = Math.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
ItemStack heldItem3 = event.entityPlayer.getHeldItem(); if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
heldItem3.stackSize--; && !event.entityPlayer.capabilities.isCreativeMode) {
return; ItemStack heldItem3 = event.entityPlayer.getHeldItem();
} heldItem3.stackSize--;
} return;
}
}
if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem()) && Gardening.addWeedKiller(event.world, event.x, y, event.z) && !event.entityPlayer.capabilities.isCreativeMode) { if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem())
ItemStack heldItem4 = event.entityPlayer.getHeldItem(); && Gardening.addWeedKiller(event.world, event.x, y, event.z)
heldItem4.stackSize--; && !event.entityPlayer.capabilities.isCreativeMode) {
} ItemStack heldItem4 = event.entityPlayer.getHeldItem();
} heldItem4.stackSize--;
}
}
@SubscribeEvent @SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) { public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.world; World world = event.world;
int x = event.x; int x = event.x;
int y = event.y; int y = event.y;
int z = event.z; int z = event.z;
Block block = world.getBlock(x, y - 1, z); Block block = world.getBlock(x, y - 1, z);
if (!(block instanceof IBlockSoil)) { if (!(block instanceof IBlockSoil)) {
return; return;
} }
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand); IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
if (flower != null) { if (flower != null) {
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile()); Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
} }
} }
@Deprecated @Deprecated
public void onPlantVanilla(PlayerInteractEvent event) { public void onPlantVanilla(PlayerInteractEvent event) {
if (!BinnieCore.proxy.isSimulating(event.world) || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { if (!BinnieCore.proxy.isSimulating(event.world)
return; || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
} return;
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) { }
return; if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
} return;
}
World world = event.world; World world = event.world;
int x = event.x; int x = event.x;
int y = event.y; int y = event.y;
int z = event.z; int z = event.z;
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
int py = -1; int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) { if (block instanceof IBlockSoil
py = 1; && (world.isAirBlock(x, y + 1, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z))) {
} py = 1;
}
if (py < 0) { if (py < 0) {
return; return;
} }
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.entityPlayer.getHeldItem()); 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) { if (flower != null
ItemStack heldItem = event.entityPlayer.getHeldItem(); && Gardening.plant(world, x, y + py, z, flower, event.entityPlayer.getGameProfile())
heldItem.stackSize--; && !event.entityPlayer.capabilities.isCreativeMode) {
} ItemStack heldItem = event.entityPlayer.getHeldItem();
} heldItem.stackSize--;
}
}
@SubscribeEvent @SubscribeEvent
public void onBonemeal(BonemealEvent event) { public void onBonemeal(BonemealEvent event) {
Block block = event.world.getBlock(event.x, event.y, event.z); Block block = event.world.getBlock(event.x, event.y, event.z);
if (Gardening.isSoil(block)) { if (Gardening.isSoil(block)) {
IBlockSoil soil = (IBlockSoil) block; IBlockSoil soil = (IBlockSoil) block;
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) { if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
event.setResult(Event.Result.ALLOW); event.setResult(Event.Result.ALLOW);
} }
} }
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) { if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
event.setResult(Event.Result.ALLOW); event.setResult(Event.Result.ALLOW);
} }
} }
@Override @Override
public boolean isActive() { public boolean isActive() {
return BinnieCore.isBotanyActive(); return BinnieCore.isBotanyActive();
} }
@Mod.EventHandler @Mod.EventHandler
public void onIMC(FMLInterModComms.IMCEvent event) { public void onIMC(FMLInterModComms.IMCEvent event) {
for (FMLInterModComms.IMCMessage message : event.getMessages()) { for (FMLInterModComms.IMCMessage message : event.getMessages()) {
if (message.key.equals("add-nutrient-fertiliser-1")) { if (message.key.equals("add-nutrient-fertiliser-1")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 1); ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 1);
} }
if (message.key.equals("add-nutrient-fertiliser-2")) { if (message.key.equals("add-nutrient-fertiliser-2")) {
ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 2); ModuleGardening.queuedNutrientFertilisers.put(message.getItemStackValue(), 2);
} }
if (message.key.equals("add-acid-fertiliser-1")) { if (message.key.equals("add-acid-fertiliser-1")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 1); ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 1);
} }
if (message.key.equals("add-acid-fertiliser-2")) { if (message.key.equals("add-acid-fertiliser-2")) {
ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 2); ModuleGardening.queuedAcidFertilisers.put(message.getItemStackValue(), 2);
} }
if (message.key.equals("add-alkaline-fertiliser-1")) { if (message.key.equals("add-alkaline-fertiliser-1")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1); ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
} }
if (message.key.equals("add-alkaline-fertiliser-2")) { if (message.key.equals("add-alkaline-fertiliser-2")) {
ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1); ModuleGardening.queuedAlkalineFertilisers.put(message.getItemStackValue(), 1);
} }
} }
} }
public static class PacketHandler extends BinniePacketHandler { public static class PacketHandler extends BinniePacketHandler {
public PacketHandler() { public PacketHandler() {
super(Botany.instance); super(Botany.instance);
} }
} }
} }
@@ -9,31 +9,31 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class CreativeTabBotany extends CreativeTabs { public class CreativeTabBotany extends CreativeTabs {
public static CreativeTabs instance = new CreativeTabBotany(); public static CreativeTabs instance = new CreativeTabBotany();
public CreativeTabBotany() { public CreativeTabBotany() {
super("Botany"); super("Botany");
} }
@Override @Override
public ItemStack getIconItemStack() { public ItemStack getIconItemStack() {
return new ItemStack(Blocks.red_flower, 1, 5); return new ItemStack(Blocks.red_flower, 1, 5);
} }
@Override @Override
public String getTranslatedTabLabel() { public String getTranslatedTabLabel() {
return getTabLabel(); return getTabLabel();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getTabLabel() { public String getTabLabel() {
return I18N.localise("botany.tab.botany"); return I18N.localise("botany.tab.botany");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Item getTabIconItem() { public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.yellow_flower); return Item.getItemFromBlock(Blocks.yellow_flower);
} }
} }
@@ -1,11 +1,11 @@
package binnie.botany.api; package binnie.botany.api;
public enum EnumAcidity { public enum EnumAcidity {
ACID, ACID,
NEUTRAL, NEUTRAL,
ALKALINE; ALKALINE;
public String getID() { public String getID() {
return name().toLowerCase(); return name().toLowerCase();
} }
} }
@@ -10,37 +10,37 @@ import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot; import forestry.api.genetics.ISpeciesRoot;
public enum EnumFlowerChromosome implements IChromosomeType { public enum EnumFlowerChromosome implements IChromosomeType {
SPECIES(IAlleleFlowerSpecies.class), SPECIES(IAlleleFlowerSpecies.class),
PRIMARY(IAlleleInteger.class), PRIMARY(IAlleleInteger.class),
SECONDARY(IAlleleInteger.class), SECONDARY(IAlleleInteger.class),
FERTILITY(IAlleleInteger.class), FERTILITY(IAlleleInteger.class),
TERRITORY(IAlleleArea.class), TERRITORY(IAlleleArea.class),
EFFECT(IAlleleFlowerEffect.class), EFFECT(IAlleleFlowerEffect.class),
LIFESPAN(IAlleleInteger.class), LIFESPAN(IAlleleInteger.class),
TEMPERATURE_TOLERANCE(IAlleleTolerance.class), TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
HUMIDITY_TOLERANCE(IAlleleTolerance.class), HUMIDITY_TOLERANCE(IAlleleTolerance.class),
PH_TOLERANCE(IAlleleTolerance.class), PH_TOLERANCE(IAlleleTolerance.class),
SAPPINESS(IAlleleFloat.class), SAPPINESS(IAlleleFloat.class),
STEM(IAlleleInteger.class); STEM(IAlleleInteger.class);
private Class<? extends IAllele> cls; private Class<? extends IAllele> cls;
EnumFlowerChromosome(Class<? extends IAllele> cls) { EnumFlowerChromosome(Class<? extends IAllele> cls) {
this.cls = cls; this.cls = cls;
} }
@Override @Override
public Class<? extends IAllele> getAlleleClass() { public Class<? extends IAllele> getAlleleClass() {
return cls; return cls;
} }
@Override @Override
public String getName() { public String getName() {
return toString().toLowerCase(); return toString().toLowerCase();
} }
@Override @Override
public ISpeciesRoot getSpeciesRoot() { public ISpeciesRoot getSpeciesRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers"); return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
} }
} }
@@ -1,18 +1,18 @@
package binnie.botany.api; package binnie.botany.api;
public enum EnumFlowerStage { public enum EnumFlowerStage {
FLOWER("Flower"), FLOWER("Flower"),
SEED("Seed"), SEED("Seed"),
POLLEN("Pollen"), POLLEN("Pollen"),
NONE("NONE"); NONE("NONE");
protected String name; protected String name;
EnumFlowerStage(String name) { EnumFlowerStage(String name) {
this.name = name; this.name = name;
} }
public String getName() { public String getName() {
return name; return name;
} }
} }
@@ -1,11 +1,11 @@
package binnie.botany.api; package binnie.botany.api;
public enum EnumMoisture { public enum EnumMoisture {
DRY, DRY,
NORMAL, NORMAL,
DAMP; DAMP;
public String getID() { public String getID() {
return name().toLowerCase(); return name().toLowerCase();
} }
} }
@@ -1,11 +1,11 @@
package binnie.botany.api; package binnie.botany.api;
public enum EnumSoilType { public enum EnumSoilType {
SOIL, SOIL,
LOAM, LOAM,
FLOWERBED; FLOWERBED;
public String getID() { public String getID() {
return name().toLowerCase(); return name().toLowerCase();
} }
} }
@@ -5,5 +5,5 @@ import forestry.api.genetics.IEffectData;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IAlleleFlowerEffect extends IAlleleEffect { public interface IAlleleFlowerEffect extends IAlleleEffect {
IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z); IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z);
} }
@@ -3,9 +3,9 @@ package binnie.botany.api;
import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IAlleleSpecies;
public interface IAlleleFlowerSpecies extends IAlleleSpecies { public interface IAlleleFlowerSpecies extends IAlleleSpecies {
IFlowerType getType(); IFlowerType getType();
EnumAcidity getPH(); EnumAcidity getPH();
EnumMoisture getMoisture(); EnumMoisture getMoisture();
} }
@@ -2,5 +2,4 @@ package binnie.botany.api;
import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IBreedingTracker;
public interface IBotanistTracker extends IBreedingTracker { public interface IBotanistTracker extends IBreedingTracker {}
}
@@ -1,13 +1,13 @@
package binnie.botany.api; package binnie.botany.api;
public interface IColourMix { public interface IColourMix {
IFlowerColor getColor1(); IFlowerColor getColor1();
IFlowerColor getColor2(); IFlowerColor getColor2();
boolean isMutation(IFlowerColor color1, IFlowerColor color2); boolean isMutation(IFlowerColor color1, IFlowerColor color2);
int getChance(); int getChance();
IFlowerColor getResult(); IFlowerColor getResult();
} }
+14 -14
View File
@@ -4,30 +4,30 @@ import forestry.api.genetics.IIndividual;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IFlower extends IIndividual { public interface IFlower extends IIndividual {
@Override @Override
IFlowerGenome getGenome(); IFlowerGenome getGenome();
IFlowerGenome getMate(); IFlowerGenome getMate();
void mate(IFlower other); void mate(IFlower other);
int getAge(); int getAge();
void setAge(int age); void setAge(int age);
void age(); void age();
IFlower getOffspring(World world); IFlower getOffspring(World world);
int getMaxAge(); int getMaxAge();
boolean isWilted(); boolean isWilted();
void setWilted(boolean value); void setWilted(boolean value);
boolean hasFlowered(); boolean hasFlowered();
void setFlowered(boolean value); void setFlowered(boolean value);
void removeMate(); void removeMate();
} }
@@ -3,11 +3,11 @@ package binnie.botany.api;
import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleInteger;
public interface IFlowerColor { public interface IFlowerColor {
int getColor(boolean dis); int getColor(boolean dis);
IAlleleInteger getAllele(); IAlleleInteger getAllele();
int getID(); int getID();
String getName(); String getName();
} }
@@ -5,37 +5,37 @@ import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IGenome; import forestry.api.genetics.IGenome;
public interface IFlowerGenome extends IGenome { public interface IFlowerGenome extends IGenome {
@Override @Override
IAlleleFlowerSpecies getPrimary(); IAlleleFlowerSpecies getPrimary();
@Override @Override
IAlleleFlowerSpecies getSecondary(); IAlleleFlowerSpecies getSecondary();
IFlowerColor getPrimaryColor(); IFlowerColor getPrimaryColor();
IFlowerColor getSecondaryColor(); IFlowerColor getSecondaryColor();
IFlowerColor 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(EnumAcidity pH); boolean canTolerate(EnumAcidity pH);
boolean canTolerate(EnumMoisture moisture); boolean canTolerate(EnumMoisture moisture);
boolean canTolerate(EnumTemperature temp); boolean canTolerate(EnumTemperature temp);
} }
@@ -5,5 +5,5 @@ import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation; import forestry.api.genetics.IMutation;
public interface IFlowerMutation extends IMutation { public interface IFlowerMutation extends IMutation {
float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
} }
@@ -3,42 +3,41 @@ package binnie.botany.api;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele; import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot; import forestry.api.genetics.ISpeciesRoot;
import java.util.Collection;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Collection;
public interface IFlowerRoot extends ISpeciesRoot { public interface IFlowerRoot extends ISpeciesRoot {
@Override @Override
IFlower getMember(ItemStack stack); IFlower getMember(ItemStack stack);
@Override @Override
IFlower templateAsIndividual(IAllele[] template); IFlower templateAsIndividual(IAllele[] template);
@Override @Override
IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override @Override
IFlowerGenome templateAsGenome(IAllele[] template); IFlowerGenome templateAsGenome(IAllele[] template);
@Override @Override
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
@Override @Override
IBotanistTracker getBreedingTracker(World world, GameProfile player); IBotanistTracker getBreedingTracker(World world, GameProfile player);
@Override @Override
Collection<IFlowerMutation> getMutations(boolean shuffle); Collection<IFlowerMutation> getMutations(boolean shuffle);
EnumFlowerStage getStageType(ItemStack stack); EnumFlowerStage getStageType(ItemStack stack);
IFlower getFlower(World world, IFlowerGenome genome); IFlower getFlower(World world, IFlowerGenome genome);
void addConversion(ItemStack stack, IAllele[] template); void addConversion(ItemStack stack, IAllele[] template);
IFlower getConversion(ItemStack stack); IFlower getConversion(ItemStack stack);
Collection<IColourMix> getColourMixes(boolean shuffle); Collection<IColourMix> getColourMixes(boolean shuffle);
void registerColourMix(IColourMix colorMix); void registerColourMix(IColourMix colorMix);
} }
@@ -3,15 +3,15 @@ package binnie.botany.api;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
public interface IFlowerType { public interface IFlowerType {
IIcon getStem(EnumFlowerStage stage, boolean flowered, int section); IIcon getStem(EnumFlowerStage stage, boolean flowered, int section);
IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section); IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section);
IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section); IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section);
int getID(); int getID();
int getSections(); int getSections();
int ordinal(); int ordinal();
} }
@@ -6,19 +6,19 @@ import binnie.botany.api.EnumSoilType;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IBlockSoil { public interface IBlockSoil {
EnumAcidity getPH(World world, int x, int y, int z); EnumAcidity getPH(World world, int x, int y, int z);
EnumMoisture getMoisture(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); EnumSoilType getType(World world, int x, int y, int z);
boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel); 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 degrade(World world, int x, int y, int z, EnumSoilType minLevel);
boolean setPH(World world, int x, int y, int z, EnumAcidity pH); 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 setMoisture(World world, int x, int y, int z, EnumMoisture p4);
boolean resistsWeeds(World world, int x, int y, int z); boolean resistsWeeds(World world, int x, int y, int z);
} }
@@ -9,6 +9,8 @@ import binnie.core.block.TileEntityMetadata;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -24,123 +26,120 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
public class BlockCeramic extends Block implements IBlockMetadata { public class BlockCeramic extends Block implements IBlockMetadata {
public BlockCeramic() { public BlockCeramic() {
super(Material.rock); super(Material.rock);
setHardness(1.0f); setHardness(1.0f);
setResistance(5.0f); setResistance(5.0f);
setBlockName("ceramic"); setBlockName("ceramic");
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
} }
@Override @Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) { 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); return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z); return BlockMetadata.breakBlock(this, player, world, x, y, z);
} }
@Override @Override
public TileEntity createNewTileEntity(World var1, int i) { public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata(); return new TileEntityMetadata();
} }
@Override @Override
public boolean hasTileEntity(int meta) { public boolean hasTileEntity(int meta) {
return true; return true;
} }
@Override @Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) { public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType); super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z); TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType); return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
} }
@Override @Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) { public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack); return TileEntityMetadata.getItemDamage(itemStack);
} }
@Override @Override
public int getDroppedMeta(int blockMeta, int tileMeta) { public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta; return tileMeta;
} }
@Override @Override
public String getBlockName(ItemStack itemStack) { public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.ceramicBlock"); return I18N.localise("botany.ceramicBlock");
} }
@Override @Override
public void addBlockTooltip(ItemStack stack, List tooltip) { public void addBlockTooltip(ItemStack stack, List tooltip) {
int meta = TileEntityMetadata.getItemDamage(stack); int meta = TileEntityMetadata.getItemDamage(stack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName()); tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
} }
@Override @Override
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) { public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
dropBlockAsItem(world, x, y, z, itemStack); dropBlockAsItem(world, x, y, z, itemStack);
} }
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List itemList) { public void getSubBlocks(Item item, CreativeTabs tabs, List itemList) {
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal())); itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z); TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) { if (tile != null) {
return getIcon(side, tile.getTileMetadata()); return getIcon(side, tile.getTileMetadata());
} }
return super.getIcon(world, x, y, z, side); return super.getIcon(world, x, y, z, side);
} }
@Override @Override
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return blockIcon; return blockIcon;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "ceramic"); blockIcon = Botany.proxy.getIcon(register, "ceramic");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) { public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z); TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) { if (tile != null) {
return getRenderColor(tile.getTileMetadata()); return getRenderColor(tile.getTileMetadata());
} }
return 0xffffff; return 0xffffff;
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) { public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side); super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z); world.removeTileEntity(x, y, z);
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z); return BlockMetadata.getPickBlock(world, x, y, z);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderColor(int meta) { public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false); return EnumFlowerColor.get(meta).getColor(false);
} }
} }
File diff suppressed because it is too large. Load diff
@@ -8,35 +8,35 @@ import binnie.extratrees.api.IDesign;
import binnie.extratrees.carpentry.BlockDesign; import binnie.extratrees.carpentry.BlockDesign;
import binnie.extratrees.carpentry.DesignBlock; import binnie.extratrees.carpentry.DesignBlock;
import binnie.extratrees.carpentry.ModuleCarpentry; import binnie.extratrees.carpentry.ModuleCarpentry;
import java.util.List;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import java.util.List;
public class BlockCeramicPatterned extends BlockDesign { public class BlockCeramicPatterned extends BlockDesign {
public BlockCeramicPatterned() { public BlockCeramicPatterned() {
super(CeramicDesignSystem.instance, Material.rock); super(CeramicDesignSystem.instance, Material.rock);
setHardness(1.0f); setHardness(1.0f);
setResistance(5.0f); setResistance(5.0f);
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setBlockName("ceramicPattern"); setBlockName("ceramicPattern");
} }
@Override @Override
public ItemStack getCreativeStack(IDesign design) { public ItemStack getCreativeStack(IDesign design) {
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.WHITE), CeramicColor.get(EnumFlowerColor.BLACK), design); return ModuleCarpentry.getItemStack(
} this, CeramicColor.get(EnumFlowerColor.WHITE), CeramicColor.get(EnumFlowerColor.BLACK), design);
}
@Override @Override
public String getBlockName(DesignBlock design) { public String getBlockName(DesignBlock design) {
return I18N.localise("botany.ceramicBlock"); return I18N.localise("botany.ceramicBlock");
} }
@Override @Override
public void addBlockTooltip(ItemStack stack, List tooltip) { public void addBlockTooltip(ItemStack stack, List tooltip) {
super.addBlockTooltip(stack, tooltip); super.addBlockTooltip(stack, tooltip);
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack)); DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
tooltip.add(EnumChatFormatting.GRAY + block.getDesign().getName()); tooltip.add(EnumChatFormatting.GRAY + block.getDesign().getName());
} }
} }
@@ -10,6 +10,9 @@ import binnie.core.util.I18N;
import binnie.extratrees.ExtraTrees; import binnie.extratrees.ExtraTrees;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -25,173 +28,168 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockStained extends Block implements IBlockMetadata { public class BlockStained extends Block implements IBlockMetadata {
public BlockStained() { public BlockStained() {
super(Material.glass); super(Material.glass);
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setBlockName("stained"); setBlockName("stained");
} }
@Override @Override
public int quantityDropped(Random rand) { public int quantityDropped(Random rand) {
return 0; return 0;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderBlockPass() { public int getRenderBlockPass() {
return 1; return 1;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { 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 block2 = world.getBlock(x - Facing.offsetsXForSide[side], y - Facing.offsetsYForSide[side], z -
Block block = world.getBlock(x, y, z); // Facing.offsetsZForSide[side]);
return block != this Block block = world.getBlock(x, y, z);
&& block != ExtraTrees.blockStained return block != this && block != ExtraTrees.blockStained && super.shouldSideBeRendered(world, x, y, z, side);
&& super.shouldSideBeRendered(world, x, y, z, side); }
}
@Override @Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) { 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); return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
return BlockMetadata.breakBlock(this, player, world, x, y, z); return BlockMetadata.breakBlock(this, player, world, x, y, z);
} }
@Override @Override
public TileEntity createNewTileEntity(World var1, int i) { public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata(); return new TileEntityMetadata();
} }
@Override @Override
public boolean hasTileEntity(int meta) { public boolean hasTileEntity(int meta) {
return true; return true;
} }
@Override @Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) { public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
super.onBlockEventReceived(world, x, y, z, eventId, eventType); super.onBlockEventReceived(world, x, y, z, eventId, eventType);
TileEntity tileentity = world.getTileEntity(x, y, z); TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType); return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
} }
@Override @Override
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) { public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
return TileEntityMetadata.getItemDamage(itemStack); return TileEntityMetadata.getItemDamage(itemStack);
} }
@Override @Override
public int getDroppedMeta(int blockMeta, int tileMeta) { public int getDroppedMeta(int blockMeta, int tileMeta) {
return tileMeta; return tileMeta;
} }
@Override @Override
public String getBlockName(ItemStack itemStack) { public String getBlockName(ItemStack itemStack) {
return I18N.localise("botany.pigmentedGlass"); return I18N.localise("botany.pigmentedGlass");
} }
@Override @Override
public void addBlockTooltip(ItemStack itemStack, List tooltip) { public void addBlockTooltip(ItemStack itemStack, List tooltip) {
int meta = TileEntityMetadata.getItemDamage(itemStack); int meta = TileEntityMetadata.getItemDamage(itemStack);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName()); tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(meta).getName());
} }
@Override @Override
public void dropAsStack(World world, int x, int y, int z, ItemStack stack) { public void dropAsStack(World world, int x, int y, int z, ItemStack stack) {
dropBlockAsItem(world, x, y, z, stack); dropBlockAsItem(world, x, y, z, stack);
} }
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tab, List itemList) { public void getSubBlocks(Item item, CreativeTabs tab, List itemList) {
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal())); itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z); TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) { if (tile != null) {
return getIcon(side, tile.getTileMetadata()); return getIcon(side, tile.getTileMetadata());
} }
return super.getIcon(world, x, y, z, side); return super.getIcon(world, x, y, z, side);
} }
@Override @Override
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return blockIcon; return blockIcon;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
blockIcon = Botany.proxy.getIcon(register, "stained"); blockIcon = Botany.proxy.getIcon(register, "stained");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) { public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z); TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
if (tile != null) { if (tile != null) {
return getRenderColor(tile.getTileMetadata()); return getRenderColor(tile.getTileMetadata());
} }
return 0xffffff; return 0xffffff;
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int side) { public void breakBlock(World world, int x, int y, int z, Block block, int side) {
super.breakBlock(world, x, y, z, block, side); super.breakBlock(world, x, y, z, block, side);
world.removeTileEntity(x, y, z); world.removeTileEntity(x, y, z);
} }
@Override @Override
public boolean isWood(IBlockAccess world, int x, int y, int z) { public boolean isWood(IBlockAccess world, int x, int y, int z) {
return true; return true;
} }
@Override @Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 20; return 20;
} }
@Override @Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return true; return true;
} }
@Override @Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 5; return 5;
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, x, y, z); return BlockMetadata.getPickBlock(world, x, y, z);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderColor(int meta) { public int getRenderColor(int meta) {
return EnumFlowerColor.get(meta).getColor(false); return EnumFlowerColor.get(meta).getColor(false);
} }
} }
@@ -4,43 +4,42 @@ import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor; import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.TileEntityMetadata; import binnie.core.block.TileEntityMetadata;
import binnie.extratrees.api.IDesignMaterial; import binnie.extratrees.api.IDesignMaterial;
import net.minecraft.item.ItemStack;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.item.ItemStack;
public class CeramicColor implements IDesignMaterial { public class CeramicColor implements IDesignMaterial {
private static Map<EnumFlowerColor, CeramicColor> map; private static Map<EnumFlowerColor, CeramicColor> map;
static { static {
CeramicColor.map = new LinkedHashMap<>(); CeramicColor.map = new LinkedHashMap<>();
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
CeramicColor.map.put(c, new CeramicColor(c)); CeramicColor.map.put(c, new CeramicColor(c));
} }
} }
protected EnumFlowerColor color; protected EnumFlowerColor color;
CeramicColor(EnumFlowerColor color) { CeramicColor(EnumFlowerColor color) {
this.color = color; this.color = color;
} }
public static CeramicColor get(EnumFlowerColor c) { public static CeramicColor get(EnumFlowerColor c) {
return CeramicColor.map.get(c); return CeramicColor.map.get(c);
} }
@Override @Override
public ItemStack getStack() { public ItemStack getStack() {
return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal()); return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal());
} }
@Override @Override
public String getName() { public String getName() {
return color.getName(); return color.getName();
} }
@Override @Override
public int getColor() { public int getColor() {
return color.getColor(false); return color.getColor(false);
} }
} }
@@ -10,85 +10,94 @@ import binnie.extratrees.api.IDesignSystem;
import binnie.extratrees.api.IPattern; import binnie.extratrees.api.IPattern;
import binnie.extratrees.carpentry.DesignerManager; import binnie.extratrees.carpentry.DesignerManager;
import binnie.extratrees.carpentry.EnumPattern; import binnie.extratrees.carpentry.EnumPattern;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import java.util.HashMap;
import java.util.Map;
public class CeramicDesignSystem implements IDesignSystem { public class CeramicDesignSystem implements IDesignSystem {
public static CeramicDesignSystem instance = new CeramicDesignSystem(); public static CeramicDesignSystem instance = new CeramicDesignSystem();
protected Map<Integer, IIcon> primary; protected Map<Integer, IIcon> primary;
protected Map<Integer, IIcon> secondary; protected Map<Integer, IIcon> secondary;
CeramicDesignSystem() { CeramicDesignSystem() {
primary = new HashMap<>(); primary = new HashMap<>();
secondary = new HashMap<>(); secondary = new HashMap<>();
DesignerManager.instance.registerDesignSystem(this); DesignerManager.instance.registerDesignSystem(this);
} }
@Override @Override
public IDesignMaterial getDefaultMaterial() { public IDesignMaterial getDefaultMaterial() {
return CeramicColor.get(EnumFlowerColor.WHITE); return CeramicColor.get(EnumFlowerColor.WHITE);
} }
@Override @Override
public IDesignMaterial getDefaultMaterial2() { public IDesignMaterial getDefaultMaterial2() {
return CeramicColor.get(EnumFlowerColor.BLACK); return CeramicColor.get(EnumFlowerColor.BLACK);
} }
@Override @Override
public IDesignMaterial getMaterial(int id) { public IDesignMaterial getMaterial(int id) {
return CeramicColor.get(EnumFlowerColor.get(id)); return CeramicColor.get(EnumFlowerColor.get(id));
} }
@Override @Override
public int getMaterialIndex(IDesignMaterial id) { public int getMaterialIndex(IDesignMaterial id) {
return ((CeramicColor) id).color.ordinal(); return ((CeramicColor) id).color.ordinal();
} }
public String getTexturePath() { public String getTexturePath() {
return "ceramic"; return "ceramic";
} }
@Override @Override
public IIcon getPrimaryIcon(IPattern pattern) { public IIcon getPrimaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) { if (pattern instanceof EnumPattern) {
return primary.get(((EnumPattern) pattern).ordinal()); return primary.get(((EnumPattern) pattern).ordinal());
} }
return null; return null;
} }
@Override @Override
public IIcon getSecondaryIcon(IPattern pattern) { public IIcon getSecondaryIcon(IPattern pattern) {
if (pattern instanceof EnumPattern) { if (pattern instanceof EnumPattern) {
return secondary.get(((EnumPattern) pattern).ordinal()); return secondary.get(((EnumPattern) pattern).ordinal());
} }
return null; return null;
} }
@Override @Override
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
for (EnumPattern pattern : EnumPattern.values()) { for (EnumPattern pattern : EnumPattern.values()) {
primary.put(pattern.ordinal(), BinnieCore.proxy.getIcon(register, getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0")); primary.put(
secondary.put(pattern.ordinal(), BinnieCore.proxy.getIcon(register, getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1")); 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"));
}
}
public AbstractMod getMod() { public AbstractMod getMod() {
return Botany.instance; return Botany.instance;
} }
@Override @Override
public ItemStack getAdhesive() { public ItemStack getAdhesive() {
return BotanyItems.Mortar.get(1); return BotanyItems.Mortar.get(1);
} }
@Override @Override
public IDesignMaterial getMaterial(ItemStack stack) { public IDesignMaterial getMaterial(ItemStack stack) {
return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null; return (stack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? getMaterial(stack.getItemDamage()) : null;
} }
} }
@@ -1,71 +1,70 @@
package binnie.botany.ceramic; package binnie.botany.ceramic;
import binnie.botany.Botany; import binnie.botany.Botany;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class CeramicTileRecipe implements IRecipe { public class CeramicTileRecipe implements IRecipe {
protected ItemStack cached; protected ItemStack cached;
@Override @Override
public boolean matches(InventoryCrafting crafting, World world) { public boolean matches(InventoryCrafting crafting, World world) {
cached = getCraftingResult(crafting); cached = getCraftingResult(crafting);
return cached != null; return cached != null;
} }
@Override @Override
public ItemStack getCraftingResult(InventoryCrafting inv) { public ItemStack getCraftingResult(InventoryCrafting inv) {
Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic); Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile); Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick); Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
Item mortar = Botany.misc; Item mortar = Botany.misc;
List<ItemStack> stacks = new ArrayList<>(); List<ItemStack> stacks = new ArrayList<>();
int ix = -1; int ix = -1;
int iy = -1; int iy = -1;
for (int i = 0; i < inv.getSizeInventory(); ++i) { for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i); ItemStack stack = inv.getStackInSlot(i);
if (stack != null) { if (stack != null) {
int x = i / 3; int x = i / 3;
int y = i % 3; int y = i % 3;
if (ix == -1) { if (ix == -1) {
ix = x; ix = x;
iy = y; iy = y;
} }
if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) { if (x - ix >= 2 || y - iy >= 2 || y < iy || x < ix) {
return null; return null;
} }
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()) { Item item = stack.getItem();
ItemStack stack2 = type.getRecipe(stacks); if (item != ceramicBlock && item != ceramicTile && item != ceramicBrick && item != mortar) {
if (stack2 != null) { return null;
return stack2; }
} stacks.add(stack);
} }
return null; }
}
@Override for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
public int getRecipeSize() { ItemStack stack2 = type.getRecipe(stacks);
return 2; if (stack2 != null) {
} return stack2;
}
}
return null;
}
@Override @Override
public ItemStack getRecipeOutput() { public int getRecipeSize() {
return cached; return 2;
} }
@Override
public ItemStack getRecipeOutput() {
return cached;
}
} }
@@ -9,51 +9,54 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
public class PigmentRecipe implements IRecipe { public class PigmentRecipe implements IRecipe {
protected ItemStack cached; protected ItemStack cached;
private ItemStack unknown; private ItemStack unknown;
public PigmentRecipe() { public PigmentRecipe() {
unknown = null; unknown = null;
} }
@Override @Override
public boolean matches(InventoryCrafting crafting, World world) { public boolean matches(InventoryCrafting crafting, World world) {
return getCraftingResult(crafting) != null; return getCraftingResult(crafting) != null;
} }
@Override @Override
public ItemStack getRecipeOutput() { public ItemStack getRecipeOutput() {
if (cached != null) { if (cached != null) {
return cached; return cached;
} }
return unknown; return unknown;
} }
@Override @Override
public ItemStack getCraftingResult(InventoryCrafting crafting) { public ItemStack getCraftingResult(InventoryCrafting crafting) {
int n = 0; int n = 0;
ItemStack stack = null; ItemStack stack = null;
for (int i = 0; i < crafting.getSizeInventory(); ++i) { for (int i = 0; i < crafting.getSizeInventory(); ++i) {
if (crafting.getStackInSlot(i) != null) { if (crafting.getStackInSlot(i) != null) {
if (++n > 1) { if (++n > 1) {
return null; return null;
} }
if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) { if (!Binnie.Genetics.getFlowerRoot().isMember(crafting.getStackInSlot(i))) {
continue; continue;
} }
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i)); IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(crafting.getStackInSlot(i));
if (flower.getAge() >= 1) { if (flower.getAge() >= 1) {
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID()); stack = new ItemStack(
} Botany.pigment,
} 1,
} flower.getGenome().getPrimaryColor().getID());
return stack; }
} }
}
return stack;
}
@Override @Override
public int getRecipeSize() { public int getRecipeSize() {
return 1; return 1;
} }
} }
@@ -4,9 +4,9 @@ import binnie.botany.api.IFlowerRoot;
import binnie.botany.genetics.FlowerHelper; import binnie.botany.genetics.FlowerHelper;
public class BotanyCore { public class BotanyCore {
public static IFlowerRoot speciesRoot = new FlowerHelper(); public static IFlowerRoot speciesRoot = new FlowerHelper();
public static IFlowerRoot getFlowerRoot() { public static IFlowerRoot getFlowerRoot() {
return BotanyCore.speciesRoot; return BotanyCore.speciesRoot;
} }
} }
+14 -14
View File
@@ -8,19 +8,19 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
public enum BotanyGUI implements IBinnieGUID { public enum BotanyGUI implements IBinnieGUID {
Database, Database,
DatabaseNEI; DatabaseNEI;
@Override @Override
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) { public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
Window window = null; Window window = null;
switch (this) { switch (this) {
case Database: case Database:
case DatabaseNEI: { case DatabaseNEI: {
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database); window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
break; break;
} }
} }
return window; return window;
} }
} }
@@ -3,18 +3,18 @@ package binnie.botany.core;
import binnie.core.IInitializable; import binnie.core.IInitializable;
public class ModuleCore implements IInitializable { public class ModuleCore implements IInitializable {
@Override @Override
public void preInit() { public void preInit() {
// ignored // ignored
} }
@Override @Override
public void init() { public void init() {
// ignored // ignored
} }
@Override @Override
public void postInit() { public void postInit() {
// ignored // ignored
} }
} }
@@ -11,33 +11,33 @@ import binnie.core.craftgui.controls.core.IControlValue;
import binnie.core.craftgui.geometry.IArea; import binnie.core.craftgui.geometry.IArea;
public class ControlColorDisplay extends Control implements IControlValue<IFlowerColor>, ITooltip { public class ControlColorDisplay extends Control implements IControlValue<IFlowerColor>, ITooltip {
private IFlowerColor value; private IFlowerColor value;
public ControlColorDisplay(IWidget parent, float x, float y) { public ControlColorDisplay(IWidget parent, float x, float y) {
super(parent, x, y, 16.0f, 16.0f); super(parent, x, y, 16.0f, 16.0f);
addAttribute(WidgetAttribute.MOUSE_OVER); addAttribute(WidgetAttribute.MOUSE_OVER);
} }
@Override @Override
public IFlowerColor getValue() { public IFlowerColor getValue() {
return value; return value;
} }
@Override @Override
public void setValue(IFlowerColor value) { public void setValue(IFlowerColor value) {
this.value = value; this.value = value;
} }
@Override @Override
public void onRenderBackground() { public void onRenderBackground() {
IArea area = getArea(); IArea area = getArea();
CraftGUI.render.solid(area, -1); CraftGUI.render.solid(area, -1);
CraftGUI.render.solid(area.inset(1), 0xff000000 + getValue().getColor(false)); CraftGUI.render.solid(area.inset(1), 0xff000000 + getValue().getColor(false));
} }
@Override @Override
public void getTooltip(Tooltip tooltip) { public void getTooltip(Tooltip tooltip) {
super.getTooltip(tooltip); super.getTooltip(tooltip);
tooltip.add(value.getName()); tooltip.add(value.getName());
} }
} }
@@ -5,20 +5,20 @@ import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.listbox.ControlListBox; import binnie.core.craftgui.controls.listbox.ControlListBox;
public class ControlColorMixBox extends ControlListBox<IColourMix> { public class ControlColorMixBox extends ControlListBox<IColourMix> {
private Type type; private Type type;
public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) { public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) {
super(parent, x, y, width, height, 12.0f); super(parent, x, y, width, height, 12.0f);
this.type = type; this.type = type;
} }
@Override @Override
public IWidget createOption(IColourMix value, int y) { public IWidget createOption(IColourMix value, int y) {
return new ControlColorMixItem(getContent(), value, y); return new ControlColorMixItem(getContent(), value, y);
} }
enum Type { enum Type {
Resultant, Resultant,
Further Further
} }
} }
@@ -5,26 +5,26 @@ import binnie.core.craftgui.controls.listbox.ControlList;
import binnie.core.craftgui.controls.listbox.ControlOption; import binnie.core.craftgui.controls.listbox.ControlOption;
public class ControlColorMixItem extends ControlOption<IColourMix> { public class ControlColorMixItem extends ControlOption<IColourMix> {
protected ControlColorDisplay itemWidget1; protected ControlColorDisplay itemWidget1;
protected ControlColorDisplay itemWidget2; protected ControlColorDisplay itemWidget2;
protected ControlColorDisplay itemWidget3; protected ControlColorDisplay itemWidget3;
protected ControlColourMixSymbol addSymbol; protected ControlColourMixSymbol addSymbol;
protected ControlColourMixSymbol arrowSymbol; protected ControlColourMixSymbol arrowSymbol;
public ControlColorMixItem(ControlList<IColourMix> controlList, IColourMix option, int y) { public ControlColorMixItem(ControlList<IColourMix> controlList, IColourMix option, int y) {
super(controlList, option, y); super(controlList, option, y);
itemWidget1 = new ControlColorDisplay(this, 4.0f, 4.0f); itemWidget1 = new ControlColorDisplay(this, 4.0f, 4.0f);
itemWidget2 = new ControlColorDisplay(this, 44.0f, 4.0f); itemWidget2 = new ControlColorDisplay(this, 44.0f, 4.0f);
itemWidget3 = new ControlColorDisplay(this, 104.0f, 4.0f); itemWidget3 = new ControlColorDisplay(this, 104.0f, 4.0f);
addSymbol = new ControlColourMixSymbol(this, 24, 4, 0); addSymbol = new ControlColourMixSymbol(this, 24, 4, 0);
arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1); arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1);
if (getValue() != null) { if (getValue() != null) {
itemWidget1.setValue(getValue().getColor1()); itemWidget1.setValue(getValue().getColor1());
itemWidget2.setValue(getValue().getColor2()); itemWidget2.setValue(getValue().getColor2());
itemWidget3.setValue(getValue().getResult()); itemWidget3.setValue(getValue().getResult());
addSymbol.setValue(getValue()); addSymbol.setValue(getValue());
arrowSymbol.setValue(getValue()); arrowSymbol.setValue(getValue());
} }
} }
} }
@@ -9,20 +9,21 @@ import binnie.core.craftgui.geometry.CraftGUIUtil;
import binnie.core.craftgui.geometry.IPoint; import binnie.core.craftgui.geometry.IPoint;
public class ControlColorOption extends ControlTextOption<IFlowerColor> { public class ControlColorOption extends ControlTextOption<IFlowerColor> {
protected ControlColorDisplay controlBee; protected ControlColorDisplay controlBee;
protected IPoint boxPosition; protected IPoint boxPosition;
public ControlColorOption(ControlList<IFlowerColor> controlList, IFlowerColor option, int y) { public ControlColorOption(ControlList<IFlowerColor> controlList, IFlowerColor option, int y) {
super(controlList, option, option.getName(), y); super(controlList, option, option.getName(), y);
setSize(new IPoint(getSize().x(), 20.0f)); setSize(new IPoint(getSize().x(), 20.0f));
(controlBee = new ControlColorDisplay(this, 2.0f, 2.0f)).setValue(option); (controlBee = new ControlColorDisplay(this, 2.0f, 2.0f)).setValue(option);
addAttribute(WidgetAttribute.MOUSE_OVER); addAttribute(WidgetAttribute.MOUSE_OVER);
CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f)); CraftGUIUtil.moveWidget(textWidget, new IPoint(22.0f, 0.0f));
textWidget.setSize(textWidget.getSize().sub(new IPoint(24.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 th = (int) CraftGUI.render.textHeight(
int height = Math.max(20, th + 6); textWidget.getValue(), textWidget.getSize().x());
setSize(new IPoint(size().x(), height)); int height = Math.max(20, th + 6);
textWidget.setSize(new IPoint(textWidget.getSize().x(), height)); setSize(new IPoint(size().x(), height));
boxPosition = new IPoint(2.0f, (height - 18) / 2); textWidget.setSize(new IPoint(textWidget.getSize().x(), height));
} boxPosition = new IPoint(2.0f, (height - 18) / 2);
}
} }
@@ -14,39 +14,39 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.util.I18N; import binnie.core.util.I18N;
public class ControlColourMixSymbol extends Control implements ITooltip { public class ControlColourMixSymbol extends Control implements ITooltip {
protected static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2); 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 static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
protected IColourMix value; protected IColourMix value;
protected int type; protected int type;
protected ControlColourMixSymbol(IWidget parent, int x, int y, int type) { protected ControlColourMixSymbol(IWidget parent, int x, int y, int type) {
super(parent, x, y, 16 + type * 16, 16.0f); super(parent, x, y, 16 + type * 16, 16.0f);
this.type = type; this.type = type;
value = null; value = null;
addAttribute(WidgetAttribute.MOUSE_OVER); addAttribute(WidgetAttribute.MOUSE_OVER);
} }
@Override @Override
public void onRenderBackground() { public void onRenderBackground() {
super.onRenderBackground(); super.onRenderBackground();
if (type == 0) { if (type == 0) {
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO); CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
} else { } else {
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO); CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
} }
} }
public void setValue(IColourMix value) { public void setValue(IColourMix value) {
this.value = value; this.value = value;
setColor(0xffffff); setColor(0xffffff);
} }
@Override @Override
public void getTooltip(Tooltip tooltip) { public void getTooltip(Tooltip tooltip) {
if (type == 1) { if (type == 1) {
float chance = value.getChance(); float chance = value.getChance();
tooltip.add(I18N.localise("botany.gui.controls.colorMixSymbol.chance", chance)); tooltip.add(I18N.localise("botany.gui.controls.colorMixSymbol.chance", chance));
} }
} }
} }
@@ -9,28 +9,27 @@ import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.database.DatabaseTab; import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageAbstract; import binnie.core.craftgui.database.PageAbstract;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PageColorMix extends PageAbstract<IFlowerColor> { public class PageColorMix extends PageAbstract<IFlowerColor> {
ControlText title; ControlText title;
ControlColorMixBox list; ControlColorMixBox list;
public PageColorMix(IWidget parent, DatabaseTab tab) { public PageColorMix(IWidget parent, DatabaseTab tab) {
super(parent, tab); super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageColorFurtherTitle")); title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageColorFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further); list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further);
} }
@Override @Override
public void onValueChanged(IFlowerColor colour) { public void onValueChanged(IFlowerColor colour) {
List<IColourMix> mixes = new ArrayList<>(); List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) { for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getColor1() == colour || mix.getColor2() == colour) { if (mix.getColor1() == colour || mix.getColor2() == colour) {
mixes.add(mix); mixes.add(mix);
} }
} }
list.setOptions(mixes); list.setOptions(mixes);
} }
} }
@@ -9,28 +9,27 @@ import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.database.DatabaseTab; import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageAbstract; import binnie.core.craftgui.database.PageAbstract;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PageColorMixResultant extends PageAbstract<IFlowerColor> { public class PageColorMixResultant extends PageAbstract<IFlowerColor> {
protected ControlText title; protected ControlText title;
protected ControlColorMixBox list; protected ControlColorMixBox list;
public PageColorMixResultant(IWidget parent, DatabaseTab tab) { public PageColorMixResultant(IWidget parent, DatabaseTab tab) {
super(parent, tab); super(parent, tab);
title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageSpeciesFurtherTitle")); title = new ControlTextCentered(this, 8.0f, I18N.localise("botany.gui.controls.pageSpeciesFurtherTitle"));
list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant); list = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant);
} }
@Override @Override
public void onValueChanged(IFlowerColor color) { public void onValueChanged(IFlowerColor color) {
List<IColourMix> mixes = new ArrayList<>(); List<IColourMix> mixes = new ArrayList<>();
for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) { for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
if (mix.getResult() == color) { if (mix.getResult() == color) {
mixes.add(mix); mixes.add(mix);
} }
} }
list.setOptions(mixes); list.setOptions(mixes);
} }
} }
@@ -25,84 +25,137 @@ import forestry.api.genetics.IIndividual;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class PageSpeciesFlowerGenome extends PageSpecies { public class PageSpeciesFlowerGenome extends PageSpecies {
public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) { public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab); super(parent, tab);
} }
@Override @Override
public void onValueChanged(IAlleleSpecies species) { public void onValueChanged(IAlleleSpecies species) {
deleteAllChildren(); deleteAllChildren();
IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID()); IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID());
if (template == null) { if (template == null) {
return; return;
} }
IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template); IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
if (tree == null) { if (tree == null) {
return; return;
} }
IFlowerGenome genome = tree.getGenome(); IFlowerGenome genome = tree.getGenome();
IAlleleFlowerSpecies treeSpecies = genome.getPrimary(); IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
int w = 144; int w = 144;
int h = 176; 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); new ControlText(
ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f); this,
Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16); 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 tw = w - 8 - 12;
int w2 = 55; int w2 = 55;
int w3 = tw - 50; int w3 = tw - 50;
int y = 0; int y = 0;
int th = 14; int th = 14;
int valueX = w2 + 4; 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(
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getTemperature()), TextJustification.MIDDLE_LEFT); contents,
y += th; 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(
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getMoisture()), TextJustification.MIDDLE_LEFT); contents,
y += th; 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(
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getPH()), TextJustification.MIDDLE_LEFT); contents,
y += th; 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(
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT); contents,
y += th; 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; float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
String lifespanValue = String.format("%.2f", lifespan); 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(
new ControlText(contents, new IArea(valueX, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT); contents,
y += th; 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(
new ControlText(contents, new IArea(valueX, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFT); contents,
y += th; 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 x = w2;
int tot = 0; int tot = 0;
for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) { for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
if (vid.getGenome().getPrimary() == treeSpecies) { if (vid.getGenome().getPrimary() == treeSpecies) {
if (tot > 0 && tot % 3 == 0) { if (tot > 0 && tot % 3 == 0) {
x -= 54; x -= 54;
y += 18; y += 18;
} }
ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER.ordinal()); ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER.ordinal());
ControlItemDisplay display = new ControlItemDisplay(contents, x, y); ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
display.setItemStack(stack); display.setItemStack(stack);
tot++; tot++;
x += 18; x += 18;
} }
} }
int numOfLines = 1 + (tot - 1) / 3; 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); new ControlText(
y += th; contents,
contents.setSize(new IPoint(contents.size().x(), y)); new IArea(0.0f, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines),
scrollable.setScrollableContent(contents); I18N.localise("botany.gui.database.tab.genome.varieties"),
} TextJustification.MIDDLE_RIGHT);
y += th;
contents.setSize(new IPoint(contents.size().x(), y));
scrollable.setScrollableContent(contents);
}
} }
@@ -21,71 +21,71 @@ import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.minecraft.Window; import binnie.core.craftgui.minecraft.Window;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
public class WindowBotanistDatabase extends WindowAbstractDatabase { public class WindowBotanistDatabase extends WindowAbstractDatabase {
public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) { public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) {
super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f); super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f);
} }
public static Window create(EntityPlayer player, Side side, boolean nei) { public static Window create(EntityPlayer player, Side side, boolean nei) {
return new WindowBotanistDatabase(player, side, nei); return new WindowBotanistDatabase(player, side, nei);
} }
@Override @Override
protected void addTabs() { protected void addTabs() {
new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.overview")); new PageSpeciesOverview(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.overview"));
new PageSpeciesFlowerGenome(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "genome")); new PageSpeciesFlowerGenome(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "genome"));
new PageSpeciesClassification(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.classification")); new PageSpeciesClassification(
new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.resultant")); getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.classification"));
new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.further")); new PageSpeciesResultant(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.resultant"));
new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview")); new PageSpeciesMutations(getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.further"));
new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.species")); new PageBranchOverview(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview"));
createMode(FlowerMode.COLOR, new ColorModeWidget()); new PageBranchSpecies(getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.species"));
new PageColorMixResultant(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.resultant")); createMode(FlowerMode.COLOR, new ColorModeWidget());
new PageColorMix(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.further")); new PageColorMixResultant(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.resultant"));
new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(Botany.instance, "breeder")); new PageColorMix(getInfoPages(FlowerMode.COLOR), new DatabaseTab(Botany.instance, "colour.further"));
} new PageBreeder(getInfoPages(Mode.Breeder), getUsername(), new DatabaseTab(Botany.instance, "breeder"));
}
@Override @Override
protected AbstractMod getMod() { protected AbstractMod getMod() {
return Botany.instance; return Botany.instance;
} }
@Override @Override
protected String getName() { protected String getName() {
return I18N.localise("botany.gui.database.name"); return I18N.localise("botany.gui.database.name");
} }
enum FlowerMode implements IDatabaseMode { enum FlowerMode implements IDatabaseMode {
COLOR; COLOR;
@Override @Override
public String getName() { public String getName() {
return I18N.localise("botany.gui.database.tab." + name().toLowerCase()); return I18N.localise("botany.gui.database.tab." + name().toLowerCase());
} }
} }
private class ColorModeWidget extends ModeWidgets { private class ColorModeWidget extends ModeWidgets {
public ColorModeWidget() { public ColorModeWidget() {
super(FlowerMode.COLOR, WindowBotanistDatabase.this); super(FlowerMode.COLOR, WindowBotanistDatabase.this);
} }
@Override @Override
public void createListBox(IArea area) { public void createListBox(IArea area) {
listBox = new ControlListBox<IFlowerColor>(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) { listBox = new ControlListBox<IFlowerColor>(modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
@Override @Override
public IWidget createOption(IFlowerColor value, int y) { public IWidget createOption(IFlowerColor value, int y) {
return new ControlColorOption(getContent(), value, y); return new ControlColorOption(getContent(), value, y);
} }
}; };
List<IFlowerColor> colors = new ArrayList<>(); List<IFlowerColor> colors = new ArrayList<>();
Collections.addAll(colors, EnumFlowerColor.values()); Collections.addAll(colors, EnumFlowerColor.values());
listBox.setOptions(colors); listBox.setOptions(colors);
} }
} }
} }
@@ -11,97 +11,100 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
public class CircuitGarden extends BinnieCircuit { public class CircuitGarden extends BinnieCircuit {
private boolean isManual; private boolean isManual;
private boolean isFertilised; private boolean isFertilised;
private ItemStack icon; private ItemStack icon;
private EnumMoisture moisture; private EnumMoisture moisture;
private EnumAcidity acidity; private EnumAcidity acidity;
public CircuitGarden(EnumMoisture moisture, EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) { public CircuitGarden(
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); EnumMoisture moisture,
this.moisture = moisture; EnumAcidity ph,
this.icon = icon; boolean manual,
isManual = manual; boolean fertilised,
isFertilised = fertilised; ItemStack recipe,
acidity = ph; ItemStack icon) {
String info = ""; super(
"garden." + moisture.getID() + ((ph != null) ? ("." + ph.getID()) : "") + (manual ? ".manual" : "")
+ (fertilised ? ".fert" : ""),
4,
manual
? ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual")
: ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"),
recipe);
this.moisture = moisture;
this.icon = icon;
isManual = manual;
isFertilised = fertilised;
acidity = ph;
String info = "";
if (moisture == EnumMoisture.DRY) { if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.dry") + EnumChatFormatting.RESET;
+ I18N.localise("botany.moisture.dry") }
+ EnumChatFormatting.RESET;
}
if (moisture == EnumMoisture.DAMP) { if (moisture == EnumMoisture.DAMP) {
info += EnumChatFormatting.YELLOW info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.damp") + EnumChatFormatting.RESET;
+ I18N.localise("botany.moisture.damp") }
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ACID) { if (acidity == EnumAcidity.ACID) {
if (info.length() > 0) { if (info.length() > 0) {
info += ", "; info += ", ";
} }
info += EnumChatFormatting.RED info += EnumChatFormatting.RED + I18N.localise("botany.ph.acid") + EnumChatFormatting.RESET;
+ I18N.localise("botany.ph.acid") }
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.NEUTRAL) { if (acidity == EnumAcidity.NEUTRAL) {
if (info.length() > 0) { if (info.length() > 0) {
info += ", "; info += ", ";
} }
info += EnumChatFormatting.GREEN info += EnumChatFormatting.GREEN + I18N.localise("botany.ph.neutral") + EnumChatFormatting.RESET;
+ I18N.localise("botany.ph.neutral") }
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ALKALINE) { if (acidity == EnumAcidity.ALKALINE) {
if (info.length() > 0) { if (info.length() > 0) {
info += ", "; info += ", ";
} }
info += EnumChatFormatting.AQUA info += EnumChatFormatting.AQUA + I18N.localise("botany.ph.alkaline") + EnumChatFormatting.RESET;
+ I18N.localise("botany.ph.alkaline") }
+ EnumChatFormatting.RESET;
}
if (info.length() > 0) { if (info.length() > 0) {
info = " (" + info + EnumChatFormatting.RESET + ")"; info = " (" + info + EnumChatFormatting.RESET + ")";
} }
addTooltipString(I18N.localise("botany.circuit.flowers") + info); addTooltipString(I18N.localise("botany.circuit.flowers") + info);
} }
@Override @Override
public boolean isCircuitable(Object tile) { public boolean isCircuitable(Object tile) {
return tile instanceof IFarmHousing; return tile instanceof IFarmHousing;
} }
@Override @Override
public void onInsertion(int slot, Object tile) { public void onInsertion(int slot, Object tile) {
if (!isCircuitable(tile)) { if (!isCircuitable(tile)) {
return; return;
} }
GardenLogic logic = new GardenLogic((IFarmHousing) tile); GardenLogic logic = new GardenLogic((IFarmHousing) tile);
logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName())); logic.setData(moisture, acidity, isManual, isFertilised, icon, I18N.localise(getName()));
((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic); ((IFarmHousing) tile).setFarmLogic(FarmDirection.values()[slot], logic);
} }
@Override @Override
public void onLoad(int slot, Object tile) { public void onLoad(int slot, Object tile) {
onInsertion(slot, tile); onInsertion(slot, tile);
} }
@Override @Override
public void onRemoval(int slot, Object tile) { public void onRemoval(int slot, Object tile) {
if (!isCircuitable(tile)) { if (!isCircuitable(tile)) {
return; return;
} }
((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]); ((IFarmHousing) tile).resetFarmLogic(FarmDirection.values()[slot]);
} }
@Override @Override
public void onTick(int arg0, Object arg1) { public void onTick(int arg0, Object arg1) {
// ignored // ignored
} }
} }
+35 -36
View File
@@ -10,49 +10,48 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public abstract class FarmLogic implements IFarmLogic { public abstract class FarmLogic implements IFarmLogic {
protected World world; protected World world;
protected IFarmHousing housing; protected IFarmHousing housing;
protected boolean isManual; protected boolean isManual;
public FarmLogic(IFarmHousing housing) { public FarmLogic(IFarmHousing housing) {
this.housing = housing; this.housing = housing;
} }
@Override @Override
public IFarmLogic setManual(boolean flag) { public IFarmLogic setManual(boolean flag) {
isManual = flag; isManual = flag;
return this; return this;
} }
protected boolean isAirBlock(Vect position) { protected boolean isAirBlock(Vect position) {
return world.isAirBlock(position.x, position.y, position.z); return world.isAirBlock(position.x, position.y, position.z);
} }
protected boolean isWaterBlock(Vect position) { protected boolean isWaterBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z) == Blocks.water; return world.getBlock(position.x, position.y, position.z) == Blocks.water;
} }
protected Block getBlock(Vect position) { protected Block getBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z); return world.getBlock(position.x, position.y, position.z);
} }
protected int getBlockMeta(Vect position) { protected int getBlockMeta(Vect position) {
return world.getBlockMetadata(position.x, position.y, position.z); return world.getBlockMetadata(position.x, position.y, position.z);
} }
protected ItemStack getAsItemStack(Vect position) { protected ItemStack getAsItemStack(Vect position) {
return new ItemStack(getBlock(position), 1, getBlockMeta(position)); return new ItemStack(getBlock(position), 1, getBlockMeta(position));
} }
protected Vect translateWithOffset(int x, int y, int z, FarmDirection direction, int step) { protected Vect translateWithOffset(int x, int y, int z, FarmDirection direction, int step) {
return new Vect( return new Vect(
x + direction.getForgeDirection().offsetX * step, x + direction.getForgeDirection().offsetX * step,
y + direction.getForgeDirection().offsetY * step, y + direction.getForgeDirection().offsetY * step,
z + direction.getForgeDirection().offsetZ * step z + direction.getForgeDirection().offsetZ * step);
); }
}
protected void setBlock(Vect position, Block block, int meta) { protected void setBlock(Vect position, Block block, int meta) {
world.setBlock(position.x, position.y, position.z, block, meta, 2); world.setBlock(position.x, position.y, position.z, block, meta, 2);
} }
} }
@@ -12,31 +12,31 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public class FarmableFlower implements IFarmable { public class FarmableFlower implements IFarmable {
@Override @Override
public boolean isSaplingAt(World world, int x, int y, int z) { public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == Botany.flower; return world.getBlock(x, y, z) == Botany.flower;
} }
@Override @Override
public ICrop getCropAt(World world, int x, int y, int z) { public ICrop getCropAt(World world, int x, int y, int z) {
return null; return null;
} }
@Override @Override
public boolean isGermling(ItemStack itemstack) { public boolean isGermling(ItemStack itemstack) {
EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack); EnumFlowerStage stage = BotanyCore.speciesRoot.getStageType(itemstack);
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED; return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
} }
@Override @Override
public boolean isWindfall(ItemStack itemstack) { public boolean isWindfall(ItemStack itemstack) {
return false; return false;
} }
@Override @Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(germling); IFlower flower = BotanyCore.getFlowerRoot().getMember(germling);
Gardening.plant(world, x, y, z, flower, player.getGameProfile()); Gardening.plant(world, x, y, z, flower, player.getGameProfile());
return true; return true;
} }
} }
@@ -8,14 +8,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public class FarmableVanillaFlower extends FarmableFlower { public class FarmableVanillaFlower extends FarmableFlower {
@Override @Override
public boolean isGermling(ItemStack itemstack) { public boolean isGermling(ItemStack itemstack) {
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null; return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
} }
@Override @Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IFlower flower = BotanyCore.getFlowerRoot().getConversion(germling); IFlower flower = BotanyCore.getFlowerRoot().getConversion(germling);
return Gardening.plant(world, x, y, z, flower, player.getGameProfile()); return Gardening.plant(world, x, y, z, flower, player.getGameProfile());
} }
} }
+340 -328
View File
@@ -17,6 +17,9 @@ import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable; import forestry.api.farming.IFarmable;
import forestry.core.access.IOwnable; import forestry.core.access.IOwnable;
import forestry.core.utils.vect.Vect; import forestry.core.utils.vect.Vect;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@@ -28,380 +31,389 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class GardenLogic extends FarmLogic { public class GardenLogic extends FarmLogic {
protected EnumMoisture moisture; protected EnumMoisture moisture;
protected EnumAcidity acidity; protected EnumAcidity acidity;
protected boolean fertilised; protected boolean fertilised;
protected String name; protected String name;
protected ArrayList<ItemStack> produce; protected ArrayList<ItemStack> produce;
protected List<IFarmable> farmables; protected List<IFarmable> farmables;
private ItemStack icon; private ItemStack icon;
public GardenLogic(IFarmHousing housing) { public GardenLogic(IFarmHousing housing) {
super(housing); super(housing);
produce = new ArrayList<>(); produce = new ArrayList<>();
farmables = new ArrayList<>(); farmables = new ArrayList<>();
farmables.add(new FarmableFlower()); farmables.add(new FarmableFlower());
farmables.add(new FarmableVanillaFlower()); farmables.add(new FarmableVanillaFlower());
} }
@Override @Override
public int getFertilizerConsumption() { public int getFertilizerConsumption() {
return fertilised ? 8 : 2; return fertilised ? 8 : 2;
} }
@Override @Override
public int getWaterConsumption(float hydrationModifier) { public int getWaterConsumption(float hydrationModifier) {
return (int) (moisture.ordinal() * 40 * hydrationModifier); return (int) (moisture.ordinal() * 40 * hydrationModifier);
} }
@Override @Override
public boolean isAcceptedResource(ItemStack stack) { public boolean isAcceptedResource(ItemStack stack) {
Item item = stack.getItem(); Item item = stack.getItem();
return Gardening.isSoil(item) return Gardening.isSoil(item)
|| item == Item.getItemFromBlock(Blocks.sand) || item == Item.getItemFromBlock(Blocks.sand)
|| item == Item.getItemFromBlock(Blocks.dirt) || item == Item.getItemFromBlock(Blocks.dirt)
|| Gardening.isAcidFertiliser(stack) || Gardening.isAcidFertiliser(stack)
|| Gardening.isAlkalineFertiliser(stack); || Gardening.isAlkalineFertiliser(stack);
} }
@Override @Override
public Collection<ItemStack> collect() { public Collection<ItemStack> collect() {
Collection<ItemStack> products = produce; Collection<ItemStack> products = produce;
produce = new ArrayList<>(); produce = new ArrayList<>();
return products; return products;
} }
@Override @Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) { public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
world = housing.getWorld(); world = housing.getWorld();
return maintainSoil(x, y, z, direction, extent) return maintainSoil(x, y, z, direction, extent)
|| !isManual && maintainWater(x, y, z, direction, extent) || !isManual && maintainWater(x, y, z, direction, extent)
|| maintainCrops(x, y + 1, z, direction, extent); || maintainCrops(x, y + 1, z, direction, extent);
} }
private boolean isWaste(ItemStack stack) { private boolean isWaste(ItemStack stack) {
return stack.getItem() == Item.getItemFromBlock(Blocks.dirt); return stack.getItem() == Item.getItemFromBlock(Blocks.dirt);
} }
private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) { private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) {
for (int i = 0; i < extent; ++i) { for (int i = 0; i < extent; ++i) {
Vect position = translateWithOffset(x, y, z, direction, i); Vect position = translateWithOffset(x, y, z, direction, i);
boolean isSoil = Gardening.isSoil(world.getBlock(position.x, position.y, position.z)); boolean isSoil = Gardening.isSoil(world.getBlock(position.x, position.y, position.z));
// remove unnecessary blocks
if (!isManual && !isSoil && !isAirBlock(position)) {
Block block = world.getBlock(position.x, position.y, position.z);
if (moisture == EnumMoisture.DAMP) {
if (block != Blocks.water) {
dropBlockAsProduction(position);
}
} else if (moisture == EnumMoisture.DRY) {
if (block != Blocks.sand) {
dropBlockAsProduction(position);
}
} else {
dropBlockAsProduction(position);
}
}
if (fertilised && isSoil) { // remove unnecessary blocks
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z); if (!isManual && !isSoil && !isAirBlock(position)) {
if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) { Block block = world.getBlock(position.x, position.y, position.z);
continue; if (moisture == EnumMoisture.DAMP) {
} if (block != Blocks.water) {
} dropBlockAsProduction(position);
}
} else if (moisture == EnumMoisture.DRY) {
if (block != Blocks.sand) {
dropBlockAsProduction(position);
}
} else {
dropBlockAsProduction(position);
}
}
if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) { if (fertilised && isSoil) {
world.setBlockToAir(position.x, position.y + 1, position.z); IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
continue; if (soil.fertilise(world, position.x, position.y, position.z, EnumSoilType.FLOWERBED)) {
} continue;
}
}
if (acidity != null && isSoil) { if (world.getBlock(position.x, position.y + 1, position.z) == Botany.plant) {
IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z); world.setBlockToAir(position.x, position.y + 1, position.z);
EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z); continue;
if (pH.ordinal() < acidity.ordinal()) { }
ItemStack stack = getAvailableAlkaline();
if (stack != null && soil.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() + 1])) {
housing.getFarmInventory().removeResources(new ItemStack[]{stack});
continue;
}
}
if (pH.ordinal() > acidity.ordinal()) { if (acidity != null && isSoil) {
ItemStack stack = getAvailableAcid(); IBlockSoil soil = (IBlockSoil) world.getBlock(position.x, position.y, position.z);
if (stack != null && soil.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() - 1])) { EnumAcidity pH = soil.getPH(world, position.x, position.y, position.z);
housing.getFarmInventory().removeResources(new ItemStack[]{stack}); if (pH.ordinal() < acidity.ordinal()) {
continue; ItemStack stack = getAvailableAlkaline();
} if (stack != null
} && soil.setPH(
} world,
position.x,
position.y,
position.z,
EnumAcidity.values()[pH.ordinal() + 1])) {
housing.getFarmInventory().removeResources(new ItemStack[] {stack});
continue;
}
}
if (!isAirBlock(position) && !world.getBlock(position.x, position.y, position.z).isReplaceable(world, position.x, position.y, position.z)) { if (pH.ordinal() > acidity.ordinal()) {
ItemStack block = getAsItemStack(position); ItemStack stack = getAvailableAcid();
ItemStack loam = getAvailableLoam(); if (stack != null
if (isWaste(block) && loam != null) { && soil.setPH(
produce.addAll(Blocks.dirt.getDrops(world, position.x, position.y, position.z, block.getItemDamage(), 0)); world,
setBlock(position, Blocks.air, 0); position.x,
return trySetSoil(position, loam); position.y,
} position.z,
} else if (!isManual) { EnumAcidity.values()[pH.ordinal() - 1])) {
if (!isWaterBlock(position)) { housing.getFarmInventory().removeResources(new ItemStack[] {stack});
if (i % 2 == 0) { continue;
return trySetSoil(position); }
} }
}
FarmDirection cclock = FarmDirection.EAST; if (!isAirBlock(position)
if (direction == FarmDirection.EAST) { && !world.getBlock(position.x, position.y, position.z)
cclock = FarmDirection.SOUTH; .isReplaceable(world, position.x, position.y, position.z)) {
} else if (direction == FarmDirection.SOUTH) { ItemStack block = getAsItemStack(position);
cclock = FarmDirection.EAST; ItemStack loam = getAvailableLoam();
} else if (direction == FarmDirection.WEST) { if (isWaste(block) && loam != null) {
cclock = FarmDirection.SOUTH; 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);
}
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1); FarmDirection cclock = FarmDirection.EAST;
ItemStack soil2 = getAsItemStack(previous); if (direction == FarmDirection.EAST) {
if (!Gardening.isSoil(soil2.getItem())) { cclock = FarmDirection.SOUTH;
trySetSoil(position); } else if (direction == FarmDirection.SOUTH) {
} cclock = FarmDirection.EAST;
} } else if (direction == FarmDirection.WEST) {
} cclock = FarmDirection.SOUTH;
} }
return false;
}
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) { Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
for (int i = 0; i < extent; ++i) { ItemStack soil2 = getAsItemStack(previous);
Vect position = translateWithOffset(x, y, z, direction, i); if (!Gardening.isSoil(soil2.getItem())) {
if (!isAirBlock(position) && !world.getBlock(x, y, z).isReplaceable(world, position.x, position.y, position.z)) { trySetSoil(position);
continue; }
} }
}
}
return false;
}
if (isWaterBlock(position)) { private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
continue; 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;
}
boolean isEnclosed = true; if (isWaterBlock(position)) {
if (world.isAirBlock(position.x + 1, position.y, position.z)) { continue;
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;
}
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP); boolean isEnclosed = true;
if (isEnclosed) { if (world.isAirBlock(position.x + 1, position.y, position.z)) {
return trySetWater(position); isEnclosed = false;
} } else if (world.isAirBlock(position.x - 1, position.y, position.z)) {
} isEnclosed = false;
return 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 ItemStack getAvailableLoam() { isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
EnumMoisture[] moistures; if (isEnclosed) {
if (moisture == EnumMoisture.DAMP) { return trySetWater(position);
moistures = new EnumMoisture[]{ }
EnumMoisture.DAMP, }
EnumMoisture.NORMAL, return false;
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
};
}
EnumAcidity[] acidities = { private ItemStack getAvailableLoam() {
EnumAcidity.NEUTRAL, EnumMoisture[] moistures;
EnumAcidity.ACID, if (moisture == EnumMoisture.DAMP) {
EnumAcidity.ALKALINE 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};
}
for (EnumMoisture moist : moistures) { EnumAcidity[] acidities = {EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE};
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)})) { for (EnumMoisture moist : moistures) {
return new ItemStack(Blocks.dirt); for (EnumAcidity acid : acidities) {
} for (Block type : new Block[] {Botany.flowerbed, Botany.loam, Botany.soil}) {
return null; int meta = acid.ordinal() * 3 + moist.ordinal();
} ItemStack[] resource = {new ItemStack(type, 1, meta)};
if (housing.getFarmInventory().hasResources(resource)) {
return resource[0];
}
}
}
}
private boolean trySetSoil(Vect position) { if (housing.getFarmInventory().hasResources(new ItemStack[] {new ItemStack(Blocks.dirt)})) {
return trySetSoil(position, getAvailableLoam()); return new ItemStack(Blocks.dirt);
} }
return null;
}
private boolean trySetSoil(Vect position, ItemStack loam) { private boolean trySetSoil(Vect position) {
ItemStack copy = loam; return trySetSoil(position, getAvailableLoam());
if (loam == null) { }
return false;
}
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) { private boolean trySetSoil(Vect position, ItemStack loam) {
loam = new ItemStack(Botany.soil, 0, 4); ItemStack copy = loam;
} if (loam == null) {
return false;
}
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage()); if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
housing.getFarmInventory().removeResources(new ItemStack[]{copy}); loam = new ItemStack(Botany.soil, 0, 4);
return true; }
}
private boolean trySetWater(Vect position) { setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000); housing.getFarmInventory().removeResources(new ItemStack[] {copy});
if (moisture == EnumMoisture.DAMP) { return true;
if (!housing.hasLiquid(water)) { }
return false;
}
setBlock(position, Blocks.water, 0); private boolean trySetWater(Vect position) {
housing.removeLiquid(water); FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
return true; if (moisture == EnumMoisture.DAMP) {
} if (!housing.hasLiquid(water)) {
return false;
}
if (moisture != EnumMoisture.DRY) { setBlock(position, Blocks.water, 0);
return trySetSoil(position); housing.removeLiquid(water);
} return true;
}
ItemStack[] sand = {new ItemStack(Blocks.sand, 1)}; if (moisture != EnumMoisture.DRY) {
if (!housing.getFarmInventory().hasResources(sand)) { return trySetSoil(position);
return false; }
}
setBlock(position, Blocks.sand, 0); ItemStack[] sand = {new ItemStack(Blocks.sand, 1)};
housing.getFarmInventory().removeResources(sand); if (!housing.getFarmInventory().hasResources(sand)) {
return true; return false;
} }
private void dropBlockAsProduction(Vect position) { setBlock(position, Blocks.sand, 0);
ItemStack stack = new ItemStack(world.getBlock(position.x, position.y, position.z)); housing.getFarmInventory().removeResources(sand);
if (stack.getItem() == null) { return true;
return; }
}
produce.add(stack);
world.setBlockToAir(position.x, position.y, position.z);
}
@Override private void dropBlockAsProduction(Vect position) {
public boolean isAcceptedGermling(ItemStack stack) { ItemStack stack = new ItemStack(world.getBlock(position.x, position.y, position.z));
for (IFarmable farmable : farmables) { if (stack.getItem() == null) {
if (farmable.isGermling(stack)) { return;
return true; }
} produce.add(stack);
} world.setBlockToAir(position.x, position.y, position.z);
return false; }
}
@Override @Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) { public boolean isAcceptedGermling(ItemStack stack) {
return null; for (IFarmable farmable : farmables) {
} if (farmable.isGermling(stack)) {
return true;
}
}
return false;
}
@Override @Override
@SideOnly(Side.CLIENT) public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public IIcon getIcon() { return null;
return icon.getIconIndex(); }
}
public void setIcon(ItemStack icon) { @Override
this.icon = icon; @SideOnly(Side.CLIENT)
} public IIcon getIcon() {
return icon.getIconIndex();
}
@Override public void setIcon(ItemStack icon) {
public ResourceLocation getSpriteSheet() { this.icon = icon;
return TextureMap.locationBlocksTexture; }
}
@Override @Override
public String getName() { public ResourceLocation getSpriteSheet() {
return name; return TextureMap.locationBlocksTexture;
} }
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) { @Override
for (int i = 0; i < extent; ++i) { public String getName() {
Vect position = translateWithOffset(x, y, z, direction, i); return name;
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) { protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
for (IFarmable farmable : farmables) { for (int i = 0; i < extent; ++i) {
boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z); Vect position = translateWithOffset(x, y, z, direction, i);
if (!success || !(housing instanceof IOwnable)) { if (isAirBlock(position)
continue; || 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;
}
TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z); private boolean trySetCrop(Vect position) {
if (!(tile instanceof TileEntityFlower)) { for (IFarmable farmable : farmables) {
return true; boolean success = housing.plantGermling(farmable, world, position.x, position.y, position.z);
} if (!success || !(housing instanceof IOwnable)) {
continue;
}
try { TileEntity tile = housing.getWorld().getTileEntity(position.x, position.y, position.z);
IOwnable housing2 = (IOwnable) housing; if (!(tile instanceof TileEntityFlower)) {
GameProfile prof = (GameProfile) IOwnable.class.getMethod("getOwnerProfile", new Class[0]).invoke(housing2); return true;
((TileEntityFlower) tile).setOwner(prof); }
} catch (Exception ex) {
// ignored
}
return true;
}
return false;
}
public ItemStack getAvailableAcid() { try {
for (ItemStack stack : Gardening.getAcidFertilisers()) { IOwnable housing2 = (IOwnable) housing;
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) { GameProfile prof = (GameProfile) IOwnable.class
return stack; .getMethod("getOwnerProfile", new Class[0])
} .invoke(housing2);
} ((TileEntityFlower) tile).setOwner(prof);
return null; } catch (Exception ex) {
} // ignored
}
return true;
}
return false;
}
public ItemStack getAvailableAlkaline() { public ItemStack getAvailableAcid() {
for (ItemStack stack : Gardening.getAlkalineFertilisers()) { for (ItemStack stack : Gardening.getAcidFertilisers()) {
if (stack != null && stack.getItem() != null && housing.getFarmInventory().hasResources(new ItemStack[]{stack})) { if (stack != null
return stack; && stack.getItem() != null
} && housing.getFarmInventory().hasResources(new ItemStack[] {stack})) {
} return stack;
return null; }
} }
return null;
}
public void setData(EnumMoisture moisture, EnumAcidity acidity, boolean isManual, boolean fertilised, ItemStack icon, String name) { public ItemStack getAvailableAlkaline() {
this.moisture = moisture; for (ItemStack stack : Gardening.getAlkalineFertilisers()) {
this.acidity = acidity; if (stack != null
this.isManual = isManual; && stack.getItem() != null
this.fertilised = fertilised; && housing.getFarmInventory().hasResources(new ItemStack[] {stack})) {
this.icon = icon; return stack;
this.name = name; }
} }
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;
}
} }
@@ -11,6 +11,9 @@ import binnie.core.BinnieCore;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -25,208 +28,201 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockFlower extends BlockContainer { public class BlockFlower extends BlockContainer {
public BlockFlower() { public BlockFlower() {
super(Material.plants); super(Material.plants);
float f = 0.2f; float f = 0.2f;
setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, f * 3.0f, 0.5f + f); setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, f * 3.0f, 0.5f + f);
setTickRandomly(true); setTickRandomly(true);
setBlockName("flower"); setBlockName("flower");
setStepSound(Block.soundTypeGrass); setStepSound(Block.soundTypeGrass);
} }
@Override @Override
public String getUnlocalizedName() { public String getUnlocalizedName() {
return "botany.flower"; return "botany.flower";
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return RendererBotany.renderID; return RendererBotany.renderID;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
for (EnumFlowerType type : EnumFlowerType.values()) { for (EnumFlowerType type : EnumFlowerType.values()) {
type.registerIcons(register); type.registerIcons(register);
} }
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFlower(); return new TileEntityFlower();
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null; return null;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack); super.onBlockPlacedBy(world, x, y, z, entity, stack);
TileEntity flower = world.getTileEntity(x, y, z); TileEntity flower = world.getTileEntity(x, y, z);
if (!BinnieCore.proxy.isSimulating(world)) { if (!BinnieCore.proxy.isSimulating(world)) {
if (flower != null && flower instanceof TileEntityFlower) { if (flower != null && flower instanceof TileEntityFlower) {
IFlower f = BotanyCore.getFlowerRoot().getMember(stack); IFlower f = BotanyCore.getFlowerRoot().getMember(stack);
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower)); ((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
} }
return; return;
} }
TileEntity below = world.getTileEntity(x, y - 1, z); TileEntity below = world.getTileEntity(x, y - 1, z);
if (flower != null && flower instanceof TileEntityFlower) { if (flower != null && flower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) { if (below instanceof TileEntityFlower) {
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection()); ((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
} else { } else {
GameProfile owner = (entity instanceof EntityPlayer) ? ((EntityPlayer) entity).getGameProfile() : null; GameProfile owner = (entity instanceof EntityPlayer) ? ((EntityPlayer) entity).getGameProfile() : null;
((TileEntityFlower) flower).create(stack, owner); ((TileEntityFlower) flower).create(stack, owner);
} }
} }
Gardening.tryGrowSection(world, x, y, z); Gardening.tryGrowSection(world, x, y, z);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower)) { if (!(tile instanceof TileEntityFlower)) {
return super.getIcon(world, x, y, z, side); return super.getIcon(world, x, y, z, side);
} }
TileEntityFlower f = (TileEntityFlower) tile; TileEntityFlower f = (TileEntityFlower) tile;
EnumFlowerStage stage = (f.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER; EnumFlowerStage stage = (f.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
IFlowerType flower = f.getType(); IFlowerType flower = f.getType();
int section = f.getRenderSection(); int section = f.getRenderSection();
boolean flowered = f.isFlowered(); boolean flowered = f.isFlowered();
if (RendererBotany.pass == 0) { if (RendererBotany.pass == 0) {
return flower.getStem(stage, flowered, section); return flower.getStem(stage, flowered, section);
} }
return (RendererBotany.pass == 1) ? return (RendererBotany.pass == 1)
flower.getPetalIcon(stage, flowered, section) : ? flower.getPetalIcon(stage, flowered, section)
flower.getVariantIcon(stage, flowered, section); : flower.getVariantIcon(stage, flowered, section);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) { public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) { if (tile instanceof TileEntityFlower) {
TileEntityFlower f = (TileEntityFlower) tile; TileEntityFlower f = (TileEntityFlower) tile;
if (RendererBotany.pass == 0) { if (RendererBotany.pass == 0) {
return f.getStemColour(); return f.getStemColour();
} }
return (RendererBotany.pass == 1) ? return (RendererBotany.pass == 1) ? f.getPrimaryColor() : f.getSecondaryColor();
f.getPrimaryColor() : }
f.getSecondaryColor(); return 0xffffff;
} }
return 0xffffff;
}
@Override @Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) { public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return super.canPlaceBlockAt(world, x, y, z) return super.canPlaceBlockAt(world, x, y, z) && canBlockStay(world, x, y, z);
&& canBlockStay(world, x, y, z); }
}
protected boolean canPlaceBlockOn(Block block) { protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.grass return block == Blocks.grass || block == Blocks.dirt || block == Blocks.farmland || Gardening.isSoil(block);
|| block == Blocks.dirt }
|| block == Blocks.farmland
|| Gardening.isSoil(block);
}
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block); super.onNeighborBlockChange(world, x, y, z, block);
checkAndDropBlock(world, x, y, z); checkAndDropBlock(world, x, y, z);
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower)) { if (!(tile instanceof TileEntityFlower)) {
return; return;
} }
TileEntityFlower flower = (TileEntityFlower) tile; TileEntityFlower flower = (TileEntityFlower) tile;
if (flower.getSection() == 0 if (flower.getSection() == 0
&& flower.getFlower() != null && flower.getFlower() != null
&& flower.getFlower().getAge() > 0 && flower.getFlower().getAge() > 0
&& flower.getFlower().getGenome().getPrimary().getType().getSections() > 1 && flower.getFlower().getGenome().getPrimary().getType().getSections() > 1
&& world.getBlock(x, y + 1, z) != Botany.flower) { && world.getBlock(x, y + 1, z) != Botany.flower) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} }
} }
@Override @Override
public void updateTick(World world, int x, int y, int z, Random rand) { public void updateTick(World world, int x, int y, int z, Random rand) {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) { if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand); ((TileEntityFlower) tile).randomUpdate(rand);
checkAndDropBlock(world, x, y, z); checkAndDropBlock(world, x, y, z);
return; return;
} }
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} }
protected void checkAndDropBlock(World world, int x, int y, int z) { protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!canBlockStay(world, x, y, z)) { if (!canBlockStay(world, x, y, z)) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} }
} }
@Override @Override
public boolean canBlockStay(World world, int x, int y, int z) { public boolean canBlockStay(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) { if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return world.getBlock(x, y - 1, z) == Botany.flower; return world.getBlock(x, y - 1, z) == Botany.flower;
} }
return canPlaceBlockOn(world.getBlock(x, y - 1, z)); return canPlaceBlockOn(world.getBlock(x, y - 1, z));
} }
@Override @Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) { public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>(); ArrayList<ItemStack> drops = new ArrayList<>();
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) { if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack(); ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (flower != null) { if (flower != null) {
drops.add(flower); drops.add(flower);
} }
} }
return drops; return drops;
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { 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); List<ItemStack> drops = getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
boolean hasBeenBroken = world.setBlockToAir(x, y, z); boolean hasBeenBroken = world.setBlockToAir(x, y, z);
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) { if (hasBeenBroken
for (ItemStack drop : drops) { && BinnieCore.proxy.isSimulating(world)
dropBlockAsItem(world, x, y, z, drop); && drops.size() > 0
} && (player == null || !player.capabilities.isCreativeMode)) {
} for (ItemStack drop : drops) {
return hasBeenBroken; dropBlockAsItem(world, x, y, z, drop);
} }
}
return hasBeenBroken;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) { public IIcon getIcon(int meta, int side) {
return Blocks.yellow_flower.getIcon(0, 0); return Blocks.yellow_flower.getIcon(0, 0);
} }
} }
+260 -224
View File
@@ -18,6 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.genetics.IIndividual; import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable; import forestry.api.genetics.IPollinatable;
import forestry.core.config.Config; import forestry.core.config.Config;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@@ -30,260 +31,295 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List;
public abstract class ItemBotany extends Item { public abstract class ItemBotany extends Item {
public ItemBotany(String name) { public ItemBotany(String name) {
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName(name); setUnlocalizedName(name);
hasSubtypes = true; hasSubtypes = true;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getSpriteNumber() { public int getSpriteNumber() {
return 0; return 0;
} }
@Override @Override
public boolean isDamageable() { public boolean isDamageable() {
return false; return false;
} }
@Override @Override
public boolean isRepairable() { public boolean isRepairable() {
return false; return false;
} }
@Override @Override
public boolean getShareTag() { public boolean getShareTag() {
return true; return true;
} }
@Override @Override
public boolean hasEffect(ItemStack stack, int pass) { public boolean hasEffect(ItemStack stack, int pass) {
if (!stack.hasTagCompound()) { if (!stack.hasTagCompound()) {
return false; return false;
} }
IIndividual individual = getIndividual(stack); IIndividual individual = getIndividual(stack);
return individual != null return individual != null && individual.getGenome() != null && individual.hasEffect();
&& individual.getGenome() != null }
&& individual.hasEffect();
}
@Override @Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List tooltip, boolean flag) { public void addInformation(ItemStack itemstack, EntityPlayer player, List tooltip, boolean flag) {
if (!itemstack.hasTagCompound()) { if (!itemstack.hasTagCompound()) {
return; return;
} }
IFlower individual = (IFlower) getIndividual(itemstack); IFlower individual = (IFlower) getIndividual(itemstack);
if (individual == null) { if (individual == null) {
tooltip.add(I18N.localise("botany.item.tooltip.bugged")); tooltip.add(I18N.localise("botany.item.tooltip.bugged"));
return; return;
} }
IFlowerGenome genome = individual.getGenome(); IFlowerGenome genome = individual.getGenome();
IFlowerColor primaryColor = genome.getPrimaryColor(); IFlowerColor primaryColor = genome.getPrimaryColor();
IFlowerColor secondColor = genome.getSecondaryColor(); IFlowerColor secondColor = genome.getSecondaryColor();
IFlowerColor stemColor = genome.getStemColor(); IFlowerColor stemColor = genome.getStemColor();
if (primaryColor == secondColor) { if (primaryColor == secondColor) {
tooltip.add(EnumChatFormatting.YELLOW + I18N.localise("botany.item.tooltip.flowerColor1", primaryColor.getName(), stemColor.getName())); tooltip.add(EnumChatFormatting.YELLOW
} else { + I18N.localise("botany.item.tooltip.flowerColor1", primaryColor.getName(), stemColor.getName()));
tooltip.add(EnumChatFormatting.YELLOW + I18N.localise("botany.item.tooltip.flowerColor2", primaryColor.getName(), secondColor.getName(), stemColor.getName())); } else {
} tooltip.add(EnumChatFormatting.YELLOW
+ I18N.localise(
"botany.item.tooltip.flowerColor2",
primaryColor.getName(),
secondColor.getName(),
stemColor.getName()));
}
if (individual.isAnalyzed()) { if (individual.isAnalyzed()) {
if (BinnieCore.proxy.isShiftDown()) { if (BinnieCore.proxy.isShiftDown()) {
individual.addTooltip(tooltip); individual.addTooltip(tooltip);
} else { } else {
tooltip.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.holdMore")); tooltip.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.holdMore"));
} }
} else { } else {
tooltip.add(I18N.localise("botany.item.tooltip.unknownGenome")); tooltip.add(I18N.localise("botany.item.tooltip.unknownGenome"));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) { public void registerIcons(IIconRegister par1IconRegister) {}
}
protected IIndividual getIndividual(ItemStack itemstack) { protected IIndividual getIndividual(ItemStack itemstack) {
return new Flower(itemstack.getTagCompound()); return new Flower(itemstack.getTagCompound());
} }
@Override @Override
public String getItemStackDisplayName(ItemStack itemstack) { public String getItemStackDisplayName(ItemStack itemstack) {
if (!itemstack.hasTagCompound()) { if (!itemstack.hasTagCompound()) {
return I18N.localise("botany.item.tooltip.unknown"); return I18N.localise("botany.item.tooltip.unknown");
} }
IIndividual individual = getIndividual(itemstack); IIndividual individual = getIndividual(itemstack);
if (individual != null && individual.getGenome() != null) { if (individual != null && individual.getGenome() != null) {
String tag = getTag(); String tag = getTag();
if (tag == null || tag.isEmpty()) { if (tag == null || tag.isEmpty()) {
return individual.getDisplayName(); return individual.getDisplayName();
} }
return I18N.localise("botany.item.botany.name", individual.getDisplayName(), tag); return I18N.localise("botany.item.botany.name", individual.getDisplayName(), tag);
} }
return I18N.localise("botany.item.flowerCorrupted.name"); return I18N.localise("botany.item.flowerCorrupted.name");
} }
@Override @Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
addCreativeItems(itemList, true); addCreativeItems(itemList, true);
} }
public void addCreativeItems(List itemList, boolean hideSecrets) { public void addCreativeItems(List itemList, boolean hideSecrets) {
for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) { for (IIndividual individual : BotanyCore.speciesRoot.getIndividualTemplates()) {
if (hideSecrets && individual.isSecret() && !Config.isDebug) { if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue; continue;
} }
itemList.add(BotanyCore.speciesRoot.getMemberStack(individual.copy(), getStage().ordinal())); itemList.add(BotanyCore.speciesRoot.getMemberStack(
} individual.copy(), getStage().ordinal()));
} }
}
@Override @Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) { public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack); IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null) { if (flower == null || flower.getGenome() == null) {
return 0xffffff; return 0xffffff;
} }
if (renderPass == 0) { if (renderPass == 0) {
return flower.getGenome().getStemColor().getColor(flower.isWilted()); return flower.getGenome().getStemColor().getColor(flower.isWilted());
} }
return (renderPass == 1) ? return (renderPass == 1)
flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
flower.getGenome().getSecondaryColor().getColor(flower.isWilted()); : flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
} }
@Override @Override
public boolean requiresMultipleRenderPasses() { public boolean requiresMultipleRenderPasses() {
return true; return true;
} }
@Override @Override
public int getRenderPasses(int metadata) { public int getRenderPasses(int metadata) {
return 3; return 3;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) { public IIcon getIcon(ItemStack itemstack, int renderPass) {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack); IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) { if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return EnumFlowerType.ALLIUM.getBlank(); return EnumFlowerType.ALLIUM.getBlank();
} }
IFlowerType type = flower.getGenome().getPrimary().getType(); IFlowerType type = flower.getGenome().getPrimary().getType();
if (renderPass == 0) { if (renderPass == 0) {
return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1); return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1);
} }
if (renderPass == 1) { if (renderPass == 1) {
return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1); return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
} }
return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1); return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
} }
@Override @Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) { public boolean onItemUse(
if (getStage() == EnumFlowerStage.POLLEN) { ItemStack itemstack,
IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(itemstack); EntityPlayer player,
TileEntity target = world.getTileEntity(x, y, z); World world,
if (!(target instanceof IPollinatable)) { int x,
return false; int y,
} int z,
IPollinatable pollinatable = (IPollinatable) target; int side,
if (!pollinatable.canMateWith(flower)) { float px,
return false; float py,
} float pz) {
pollinatable.mateWith(flower); if (getStage() == EnumFlowerStage.POLLEN) {
if (!player.capabilities.isCreativeMode) { IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(itemstack);
itemstack.stackSize--; TileEntity target = world.getTileEntity(x, y, z);
} if (!(target instanceof IPollinatable)) {
return true; 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 blockFlower = Botany.flower;
Block blockAlreadyThere = world.getBlock(x, y, z); Block blockAlreadyThere = world.getBlock(x, y, z);
if (blockAlreadyThere == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 0x7) < 1) { if (blockAlreadyThere == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 0x7) < 1) {
side = 1; side = 1;
} else if (blockAlreadyThere != Blocks.vine && blockAlreadyThere != Blocks.tallgrass && blockAlreadyThere != Blocks.deadbush && !blockAlreadyThere.isReplaceable(world, x, y, z)) { } else if (blockAlreadyThere != Blocks.vine
if (side == 0) { && blockAlreadyThere != Blocks.tallgrass
y--; && blockAlreadyThere != Blocks.deadbush
} else if (side == 1) { && !blockAlreadyThere.isReplaceable(world, x, y, z)) {
y++; if (side == 0) {
} else if (side == 2) { y--;
z--; } else if (side == 1) {
} else if (side == 3) { y++;
z++; } else if (side == 2) {
} else if (side == 4) { z--;
x--; } else if (side == 3) {
} else if (side == 5) { z++;
x++; } else if (side == 4) {
} x--;
} } else if (side == 5) {
x++;
}
}
if (itemstack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, itemstack)) { if (itemstack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, itemstack)) {
return false; return false;
} }
if (y == 255 && blockFlower.getMaterial().isSolid()) { if (y == 255 && blockFlower.getMaterial().isSolid()) {
return false; return false;
} }
if (world.canPlaceEntityOnSide(blockFlower, x, y, z, false, side, player, itemstack)) { if (world.canPlaceEntityOnSide(blockFlower, x, y, z, false, side, player, itemstack)) {
int i1 = getMetadata(itemstack.getItemDamage()); int i1 = getMetadata(itemstack.getItemDamage());
int j1 = blockFlower.onBlockPlaced(world, x, y, z, side, px, py, pz, i1); 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)) { 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); world.playSoundEffect(
itemstack.stackSize--; x + 0.5f,
} y + 0.5f,
return true; z + 0.5f,
} blockFlower.stepSound.func_150496_b(),
return false; (blockFlower.stepSound.getVolume() + 1.0f) / 2.0f,
} blockFlower.stepSound.getPitch() * 0.8f);
itemstack.stackSize--;
}
return true;
}
return false;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) { 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 field_150939_a = Botany.flower;
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
if (block == Blocks.snow_layer) { if (block == Blocks.snow_layer) {
side = 1; side = 1;
} else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z)) { } else if (block != Blocks.vine
if (side == 0) { && block != Blocks.tallgrass
y--; && block != Blocks.deadbush
} else if (side == 1) { && !block.isReplaceable(world, x, y, z)) {
y++; if (side == 0) {
} else if (side == 2) { y--;
z--; } else if (side == 1) {
} else if (side == 3) { y++;
z++; } else if (side == 2) {
} else if (side == 4) { z--;
x--; } else if (side == 3) {
} else if (side == 5) { z++;
x++; } else if (side == 4) {
} x--;
} } else if (side == 5) {
return world.canPlaceEntityOnSide(field_150939_a, x, y, z, false, side, null, stack); 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) { public boolean placeBlockAt(
Block block = Botany.flower; ItemStack stack,
if (!world.setBlock(x, y, z, block, metadata, 3)) { EntityPlayer player,
return false; 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) { if (world.getBlock(x, y, z) == block) {
block.onBlockPlacedBy(world, x, y, z, player, stack); block.onBlockPlacedBy(world, x, y, z, player, stack);
block.onPostBlockPlaced(world, x, y, z, metadata); block.onPostBlockPlaced(world, x, y, z, metadata);
} }
return true; return true;
} }
public abstract EnumFlowerStage getStage(); public abstract EnumFlowerStage getStage();
public abstract String getTag(); public abstract String getTag();
} }
@@ -3,17 +3,17 @@ package binnie.botany.flower;
import binnie.botany.api.EnumFlowerStage; import binnie.botany.api.EnumFlowerStage;
public class ItemFlower extends ItemBotany { public class ItemFlower extends ItemBotany {
public ItemFlower() { public ItemFlower() {
super("itemFlower"); super("itemFlower");
} }
@Override @Override
public EnumFlowerStage getStage() { public EnumFlowerStage getStage() {
return EnumFlowerStage.FLOWER; return EnumFlowerStage.FLOWER;
} }
@Override @Override
public String getTag() { public String getTag() {
return ""; return "";
} }
} }
@@ -5,6 +5,7 @@ import binnie.botany.CreativeTabBotany;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -13,155 +14,152 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import java.util.List;
public class ItemInsulatedTube extends Item { public class ItemInsulatedTube extends Item {
IIcon[] icons; IIcon[] icons;
public ItemInsulatedTube() { public ItemInsulatedTube() {
icons = new IIcon[3]; icons = new IIcon[3];
setUnlocalizedName("insulatedTube"); setUnlocalizedName("insulatedTube");
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setHasSubtypes(true); setHasSubtypes(true);
} }
public static ItemStack getInsulateStack(ItemStack stack) { public static ItemStack getInsulateStack(ItemStack stack) {
return Insulate.get(stack.getItemDamage()).getStack(); return Insulate.get(stack.getItemDamage()).getStack();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) { public void getSubItems(Item item, CreativeTabs tab, List list) {
for (Material mat : Material.values()) { for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) { for (Insulate ins : Insulate.values()) {
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128)); list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
} }
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
icons[i] = Botany.proxy.getIcon(register, "insulatedTube." + i); icons[i] = Botany.proxy.getIcon(register, "insulatedTube." + i);
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) { public int getColorFromItemStack(ItemStack stack, int pass) {
if (pass == 0) { if (pass == 0) {
return 0xffffff; return 0xffffff;
} }
return (pass == 1) return (pass == 1)
? Material.get(stack.getItemDamage()).getColor() ? Material.get(stack.getItemDamage()).getColor()
: Insulate.get(stack.getItemDamage()).getColor(); : Insulate.get(stack.getItemDamage()).getColor();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
tooltip.add(Insulate.get(stack.getItemDamage()).getName()); tooltip.add(Insulate.get(stack.getItemDamage()).getName());
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return Material.get(stack.getItemDamage()).getName() + " " return Material.get(stack.getItemDamage()).getName() + " " + I18N.localise("botany.tube.name");
+ I18N.localise("botany.tube.name"); }
}
@Override @Override
public int getRenderPasses(int metadata) { public int getRenderPasses(int metadata) {
return 3; return 3;
} }
@Override @Override
public IIcon getIcon(ItemStack stack, int pass) { public IIcon getIcon(ItemStack stack, int pass) {
return icons[pass % 3]; return icons[pass % 3];
} }
@Override @Override
public boolean requiresMultipleRenderPasses() { public boolean requiresMultipleRenderPasses() {
return true; return true;
} }
enum Material { enum Material {
Copper(0xe3b78e, "cooper"), Copper(0xe3b78e, "cooper"),
Tin(0xe1eef4, "tin"), Tin(0xe1eef4, "tin"),
Bronze(0xddc276, "bronze"), Bronze(0xddc276, "bronze"),
Iron(0xd8d8d8, "iron"); Iron(0xd8d8d8, "iron");
protected int color; protected int color;
protected String name; protected String name;
Material(int color, String name) { Material(int color, String name) {
this.color = color; this.color = color;
this.name = name; this.name = name;
} }
public static Material get(int i) { public static Material get(int i) {
return values()[i % values().length]; return values()[i % values().length];
} }
public int getColor() { public int getColor() {
return color; return color;
} }
public String getName() { public String getName() {
return I18N.localise("botany.tube." + name); return I18N.localise("botany.tube." + name);
} }
} }
enum Insulate { enum Insulate {
Clay(0xa1aacc, "clay"), Clay(0xa1aacc, "clay"),
Cobble(0x7b7b7b, "cobblestone"), Cobble(0x7b7b7b, "cobblestone"),
Sand(0xefeab5, "sand"), Sand(0xefeab5, "sand"),
HardenedClay(0x935c43, "hardenedClay"), HardenedClay(0x935c43, "hardenedClay"),
Stone(0x6d6d6d, "smoothStone"), Stone(0x6d6d6d, "smoothStone"),
Sandstone(0xc1b989, "sandstone"); Sandstone(0xc1b989, "sandstone");
protected int color; protected int color;
protected String name; protected String name;
Insulate(int color, String name) { Insulate(int color, String name) {
this.color = color; this.color = color;
this.name = name; this.name = name;
} }
public static Insulate get(int i) { public static Insulate get(int i) {
return values()[i / 128 % values().length]; return values()[i / 128 % values().length];
} }
public int getColor() { public int getColor() {
return color; return color;
} }
public String getName() { public String getName() {
return I18N.localise("botany.tube.insulate." + name); return I18N.localise("botany.tube.insulate." + name);
} }
public ItemStack getStack() { public ItemStack getStack() {
switch (this) { switch (this) {
case Clay: case Clay:
return new ItemStack(Blocks.clay); return new ItemStack(Blocks.clay);
case Cobble: case Cobble:
return new ItemStack(Blocks.cobblestone); return new ItemStack(Blocks.cobblestone);
case HardenedClay: case HardenedClay:
return new ItemStack(Blocks.hardened_clay); return new ItemStack(Blocks.hardened_clay);
case Sand: case Sand:
return new ItemStack(Blocks.sand); return new ItemStack(Blocks.sand);
case Sandstone: case Sandstone:
return new ItemStack(Blocks.sandstone); return new ItemStack(Blocks.sandstone);
case Stone: case Stone:
return new ItemStack(Blocks.stone); return new ItemStack(Blocks.stone);
} }
return null; return null;
} }
} }
} }
@@ -4,17 +4,17 @@ import binnie.botany.api.EnumFlowerStage;
import binnie.core.util.I18N; import binnie.core.util.I18N;
public class ItemPollen extends ItemBotany { public class ItemPollen extends ItemBotany {
public ItemPollen() { public ItemPollen() {
super("pollen"); super("pollen");
} }
@Override @Override
public EnumFlowerStage getStage() { public EnumFlowerStage getStage() {
return EnumFlowerStage.POLLEN; return EnumFlowerStage.POLLEN;
} }
@Override @Override
public String getTag() { public String getTag() {
return I18N.localise("botany.item.pollen.tag.name"); return I18N.localise("botany.item.pollen.tag.name");
} }
} }
@@ -4,17 +4,17 @@ import binnie.botany.api.EnumFlowerStage;
import binnie.core.util.I18N; import binnie.core.util.I18N;
public class ItemSeed extends ItemBotany { public class ItemSeed extends ItemBotany {
public ItemSeed() { public ItemSeed() {
super("seed"); super("seed");
} }
@Override @Override
public EnumFlowerStage getStage() { public EnumFlowerStage getStage() {
return EnumFlowerStage.SEED; return EnumFlowerStage.SEED;
} }
@Override @Override
public String getTag() { public String getTag() {
return I18N.localise("botany.item.germling.tag.name"); return I18N.localise("botany.item.germling.tag.name");
} }
} }
@@ -9,52 +9,53 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
public class RendererBotany implements ISimpleBlockRenderingHandler { public class RendererBotany implements ISimpleBlockRenderingHandler {
public static int renderID; public static int renderID;
public static int pass; public static int pass;
@Override @Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// ignored // ignored
} }
@Override @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { public boolean renderWorldBlock(
Tessellator tessellator = Tessellator.instance; IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); Tessellator tessellator = Tessellator.instance;
double d1 = x; tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
double d2 = y; double d1 = x;
double d3 = z; double d2 = y;
long i1 = x * 3129871 ^ z * 116129781L; double d3 = z;
i1 = i1 * i1 * 42317861L + i1 * 11L; long i1 = x * 3129871 ^ z * 116129781L;
d1 += ((i1 >> 16 & 0xFL) / 15.0f - 0.5) * 0.3; i1 = i1 * i1 * 42317861L + i1 * 11L;
d3 += ((i1 >> 24 & 0xFL) / 15.0f - 0.5) * 0.3; d1 += ((i1 >> 16 & 0xFL) / 15.0f - 0.5) * 0.3;
d3 += ((i1 >> 24 & 0xFL) / 15.0f - 0.5) * 0.3;
for (int j = 0; j < 3; ++j) { for (int j = 0; j < 3; ++j) {
RendererBotany.pass = j; RendererBotany.pass = j;
int l = block.colorMultiplier(renderer.blockAccess, x, y, z); int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
float f = (l >> 16 & 0xFF) / 255.0f; float f = (l >> 16 & 0xFF) / 255.0f;
float f2 = (l >> 8 & 0xFF) / 255.0f; float f2 = (l >> 8 & 0xFF) / 255.0f;
float f3 = (l & 0xFF) / 255.0f; float f3 = (l & 0xFF) / 255.0f;
if (EntityRenderer.anaglyphEnable) { if (EntityRenderer.anaglyphEnable) {
f = (f * 30.0f + f2 * 59.0f + f3 * 11.0f) / 100.0f; f = (f * 30.0f + f2 * 59.0f + f3 * 11.0f) / 100.0f;
f2 = (f * 30.0f + f2 * 70.0f) / 100.0f; f2 = (f * 30.0f + f2 * 70.0f) / 100.0f;
f3 = (f * 30.0f + f3 * 70.0f) / 100.0f; f3 = (f * 30.0f + f3 * 70.0f) / 100.0f;
} }
tessellator.setColorOpaque_F(f, f2, f3); tessellator.setColorOpaque_F(f, f2, f3);
IIcon iicon = block.getIcon(world, x, y, z, 0); IIcon iicon = block.getIcon(world, x, y, z, 0);
renderer.drawCrossedSquares(iicon, d1, d2, d3, 1.0f); renderer.drawCrossedSquares(iicon, d1, d2, d3, 1.0f);
} }
return false; return false;
} }
@Override @Override
public boolean shouldRender3DInInventory(int i) { public boolean shouldRender3DInInventory(int i) {
return false; return false;
} }
@Override @Override
public int getRenderId() { public int getRenderId() {
return RendererBotany.renderID; return RendererBotany.renderID;
} }
} }
File diff suppressed because it is too large. Load diff
@@ -7,6 +7,9 @@ import binnie.botany.api.gardening.IBlockSoil;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockBush; import net.minecraft.block.BlockBush;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -17,141 +20,135 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockPlant extends BlockBush { public class BlockPlant extends BlockBush {
public BlockPlant() { public BlockPlant() {
setBlockName("plant"); setBlockName("plant");
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setTickRandomly(true); setTickRandomly(true);
setStepSound(Block.soundTypeGrass); setStepSound(Block.soundTypeGrass);
} }
public static boolean isWeed(IBlockAccess world, int x, int y, int z) { public static boolean isWeed(IBlockAccess world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof BlockPlant)) { if (!(world.getBlock(x, y, z) instanceof BlockPlant)) {
return false; return false;
} }
Type type = Type.get(world.getBlockMetadata(x, y, z)); Type type = Type.get(world.getBlockMetadata(x, y, z));
return type == Type.Weeds return type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong;
|| type == Type.WeedsLong }
|| type == Type.WeedsVeryLong;
}
@Override @Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
for (Type t : Type.values()) { for (Type t : Type.values()) {
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase()); t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
} }
} }
@Override @Override
protected boolean canPlaceBlockOn(Block block) { protected boolean canPlaceBlockOn(Block block) {
return super.canPlaceBlockOn(block) || Gardening.isSoil(block); return super.canPlaceBlockOn(block) || Gardening.isSoil(block);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return Type.values()[meta % Type.values().length].icon; return Type.values()[meta % Type.values().length].icon;
} }
@Override @Override
public int damageDropped(int damage) { public int damageDropped(int damage) {
return damage; return damage;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (Type type : Type.values()) { for (Type type : Type.values()) {
list.add(type.get()); list.add(type.get());
} }
} }
@Override @Override
public void updateTick(World world, int x, int y, int z, Random random) { public void updateTick(World world, int x, int y, int z, Random random) {
Type type = Type.get(world.getBlockMetadata(x, y, z)); Type type = Type.get(world.getBlockMetadata(x, y, z));
if (random.nextInt(4) == 0) { if (random.nextInt(4) == 0) {
if (type == Type.Weeds) { if (type == Type.Weeds) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2); world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
} else if (type == Type.WeedsLong) { } else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsVeryLong.ordinal(), 2); world.setBlockMetadataWithNotify(x, y, z, Type.WeedsVeryLong.ordinal(), 2);
} else if (type == Type.DeadFlower) { } else if (type == Type.DeadFlower) {
world.setBlockMetadataWithNotify(x, y, z, Type.DecayingFlower.ordinal(), 2); world.setBlockMetadataWithNotify(x, y, z, Type.DecayingFlower.ordinal(), 2);
} else if (type == Type.DecayingFlower) { } else if (type == Type.DecayingFlower) {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
return; return;
} }
} }
if (random.nextInt(6) == 0) { if (random.nextInt(6) == 0) {
if (type == Type.Weeds) { if (type == Type.Weeds) {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} else if (type == Type.WeedsLong) { } else if (type == Type.WeedsLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.Weeds.ordinal(), 2); world.setBlockMetadataWithNotify(x, y, z, Type.Weeds.ordinal(), 2);
} else if (type == Type.WeedsVeryLong) { } else if (type == Type.WeedsVeryLong) {
world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2); world.setBlockMetadataWithNotify(x, y, z, Type.WeedsLong.ordinal(), 2);
} }
} }
Block below = world.getBlock(x, y - 1, z); Block below = world.getBlock(x, y - 1, z);
if (!Gardening.isSoil(below)) { if (!Gardening.isSoil(below)) {
return; return;
} }
IBlockSoil soil = (IBlockSoil) below; IBlockSoil soil = (IBlockSoil) below;
if (random.nextInt(3) != 0) { if (random.nextInt(3) != 0) {
return; return;
} }
if (type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong) { if (type == Type.Weeds || type == Type.WeedsLong || type == Type.WeedsVeryLong) {
if (!soil.degrade(world, x, y - 1, z, EnumSoilType.LOAM)) { if (!soil.degrade(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.degrade(world, x, y - 1, z, EnumSoilType.SOIL); soil.degrade(world, x, y - 1, z, EnumSoilType.SOIL);
} }
} else if (type == Type.DecayingFlower && !soil.fertilise(world, x, y - 1, z, EnumSoilType.LOAM)) { } else if (type == Type.DecayingFlower && !soil.fertilise(world, x, y - 1, z, EnumSoilType.LOAM)) {
soil.fertilise(world, x, y - 1, z, EnumSoilType.FLOWERBED); soil.fertilise(world, x, y - 1, z, EnumSoilType.FLOWERBED);
} }
} }
@Override @Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
return true; return true;
} }
public enum Type { public enum Type {
Weeds("weeds"), Weeds("weeds"),
WeedsLong("longWeeds"), WeedsLong("longWeeds"),
WeedsVeryLong("veryLongWeeds"), WeedsVeryLong("veryLongWeeds"),
DeadFlower("deadFlower"), DeadFlower("deadFlower"),
DecayingFlower("decayingFlower"); DecayingFlower("decayingFlower");
public IIcon icon; public IIcon icon;
protected String name; protected String name;
Type(String name) { Type(String name) {
this.name = name; this.name = name;
} }
public static Type get(int id) { public static Type get(int id) {
return values()[id % values().length]; return values()[id % values().length];
} }
public ItemStack get() { public ItemStack get() {
return new ItemStack(Botany.plant, 1, ordinal()); return new ItemStack(Botany.plant, 1, ordinal());
} }
public String getName() { public String getName() {
return I18N.localise("botany.plant." + name); return I18N.localise("botany.plant." + name);
} }
} }
} }
@@ -8,6 +8,8 @@ import binnie.botany.api.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil; import binnie.botany.api.gardening.IBlockSoil;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -22,193 +24,192 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
import java.util.Random;
public class BlockSoil extends Block implements IBlockSoil { public class BlockSoil extends Block implements IBlockSoil {
protected boolean weedKilled; protected boolean weedKilled;
protected IIcon[] iconsTop; protected IIcon[] iconsTop;
protected IIcon[] iconsSide; protected IIcon[] iconsSide;
protected IIcon[] iconsNoWeed; protected IIcon[] iconsNoWeed;
protected EnumSoilType type; protected EnumSoilType type;
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) { public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
super(Material.ground); super(Material.ground);
this.type = type; this.type = type;
this.weedKilled = weedKilled; this.weedKilled = weedKilled;
iconsTop = new IIcon[9]; iconsTop = new IIcon[9];
iconsSide = new IIcon[9]; iconsSide = new IIcon[9];
iconsNoWeed = new IIcon[9]; iconsNoWeed = new IIcon[9];
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setBlockName(blockName); setBlockName(blockName);
setTickRandomly(true); setTickRandomly(true);
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f); setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f);
setLightOpacity(255); setLightOpacity(255);
setHardness(0.5f); setHardness(0.5f);
setStepSound(Block.soundTypeGravel); setStepSound(Block.soundTypeGravel);
} }
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) { public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
return acid.ordinal() * 3 + moisture.ordinal(); return acid.ordinal() * 3 + moisture.ordinal();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
list.add(new ItemStack(this, 1, i)); list.add(new ItemStack(this, 1, i));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z)); return getIcon(side, world.getBlockMetadata(x, y, z));
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
meta = ((meta >= 9) ? 8 : meta); meta = ((meta >= 9) ? 8 : meta);
if (side == 1) { if (side == 1) {
return weedKilled ? iconsNoWeed[meta] : iconsTop[meta]; return weedKilled ? iconsNoWeed[meta] : iconsTop[meta];
} }
return (side == 0) ? Blocks.dirt.getIcon(side, 0) : iconsSide[meta]; return (side == 0) ? Blocks.dirt.getIcon(side, 0) : iconsSide[meta];
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
for (EnumMoisture moisture : EnumMoisture.values()) { for (EnumMoisture moisture : EnumMoisture.values()) {
for (EnumAcidity pH : EnumAcidity.values()) { for (EnumAcidity pH : EnumAcidity.values()) {
int index = moisture.ordinal() + pH.ordinal() * 3; int index = moisture.ordinal() + pH.ordinal() * 3;
String id = "soil/" + getType().getID() + "." + pH.getID() + "." + moisture.getID(); String id = "soil/" + getType().getID() + "." + pH.getID() + "." + moisture.getID();
iconsTop[index] = Botany.proxy.getIcon(register, id + ".0"); iconsTop[index] = Botany.proxy.getIcon(register, id + ".0");
iconsSide[index] = Botany.proxy.getIcon(register, id + ".1"); iconsSide[index] = Botany.proxy.getIcon(register, id + ".1");
iconsNoWeed[index] = Botany.proxy.getIcon(register, id + ".2"); iconsNoWeed[index] = Botany.proxy.getIcon(register, id + ".2");
} }
} }
} }
public EnumSoilType getType() { public EnumSoilType getType() {
return type; return type;
} }
@Override @Override
public int damageDropped(int damage) { public int damageDropped(int damage) {
return damage; return damage;
} }
@Override @Override
public void updateTick(World world, int x, int y, int z, Random random) { public void updateTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
EnumMoisture moisture = EnumMoisture.values()[meta % 3]; EnumMoisture moisture = EnumMoisture.values()[meta % 3];
EnumAcidity acidity = EnumAcidity.values()[meta / 3]; EnumAcidity acidity = EnumAcidity.values()[meta / 3];
EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z); EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z);
if (desiredMoisture.ordinal() > moisture.ordinal()) { if (desiredMoisture.ordinal() > moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP); moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
} }
if (desiredMoisture.ordinal() < moisture.ordinal()) { if (desiredMoisture.ordinal() < moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY); moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
} }
int meta2 = getMeta(acidity, moisture); int meta2 = getMeta(acidity, moisture);
if (meta != meta2) { if (meta != meta2) {
world.setBlockMetadataWithNotify(x, y, z, meta2, 2); world.setBlockMetadataWithNotify(x, y, z, meta2, 2);
} }
if (!weedKilled && random.nextInt(5 - getType(world, x, y, z).ordinal()) == 0 && world.getBlock(x, y + 1, z) == Blocks.air) { if (!weedKilled
world.setBlock(x, y + 1, z, Botany.plant, BlockPlant.Type.Weeds.ordinal(), 2); && random.nextInt(5 - getType(world, x, y, z).ordinal()) == 0
} && world.getBlock(x, y + 1, z) == Blocks.air) {
} world.setBlock(x, y + 1, z, Botany.plant, BlockPlant.Type.Weeds.ordinal(), 2);
}
}
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public EnumAcidity getPH(World world, int x, int y, int z) { public EnumAcidity getPH(World world, int x, int y, int z) {
return EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3]; return EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3];
} }
@Override @Override
public EnumMoisture getMoisture(World world, int x, int y, int z) { public EnumMoisture getMoisture(World world, int x, int y, int z) {
return EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3]; return EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3];
} }
@Override @Override
public EnumSoilType getType(World world, int x, int y, int z) { public EnumSoilType getType(World world, int x, int y, int z) {
return type; return type;
} }
@Override @Override
public boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel) { public boolean fertilise(World world, int x, int y, int z, EnumSoilType maxLevel) {
EnumSoilType type = getType(world, x, y, z); EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() >= maxLevel.ordinal()) { if (type.ordinal() >= maxLevel.ordinal()) {
return false; return false;
} }
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(maxLevel, weedKilled), meta, 2); return world.setBlock(x, y, z, Gardening.getSoilBlock(maxLevel, weedKilled), meta, 2);
} }
@Override @Override
public boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel) { public boolean degrade(World world, int x, int y, int z, EnumSoilType minLevel) {
EnumSoilType type = getType(world, x, y, z); EnumSoilType type = getType(world, x, y, z);
if (type.ordinal() <= minLevel.ordinal()) { if (type.ordinal() <= minLevel.ordinal()) {
return false; return false;
} }
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
return world.setBlock(x, y, z, Gardening.getSoilBlock(minLevel, weedKilled), meta, 2); return world.setBlock(x, y, z, Gardening.getSoilBlock(minLevel, weedKilled), meta, 2);
} }
@Override @Override
public boolean setPH(World world, int x, int y, int z, EnumAcidity pH) { public boolean setPH(World world, int x, int y, int z, EnumAcidity pH) {
int meta = getMeta(pH, getMoisture(world, x, y, z)); int meta = getMeta(pH, getMoisture(world, x, y, z));
return world.setBlockMetadataWithNotify(x, y, z, meta, 2); return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
} }
@Override @Override
public boolean setMoisture(World world, int x, int y, int z, EnumMoisture moisture) { public boolean setMoisture(World world, int x, int y, int z, EnumMoisture moisture) {
int meta = getMeta(getPH(world, x, y, z), moisture); int meta = getMeta(getPH(world, x, y, z), moisture);
return world.setBlockMetadataWithNotify(x, y, z, meta, 2); return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
} }
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block); super.onNeighborBlockChange(world, x, y, z, block);
if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, false)) { if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, false)) {
world.setBlock(x, y, z, Blocks.dirt, 0, 2); world.setBlock(x, y, z, Blocks.dirt, 0, 2);
} }
} }
@Override @Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { public boolean canSustainPlant(
Block plant = plantable.getPlant(world, x, y + 1, z); IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
if (plant == Botany.flower) { Block plant = plantable.getPlant(world, x, y + 1, z);
return true; if (plant == Botany.flower) {
} return true;
}
if (plant == Botany.plant) { if (plant == Botany.plant) {
return !weedKilled || !BlockPlant.isWeed(world, x, y, z); return !weedKilled || !BlockPlant.isWeed(world, x, y, z);
} }
return world instanceof World return world instanceof World && Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable);
&& Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable); }
}
@Override @Override
public boolean resistsWeeds(World world, int x, int y, int z) { public boolean resistsWeeds(World world, int x, int y, int z) {
return weedKilled; return weedKilled;
} }
} }
@@ -11,6 +11,9 @@ import binnie.botany.items.BotanyItems;
import binnie.core.BinnieCore; import binnie.core.BinnieCore;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumTemperature; import forestry.api.core.EnumTemperature;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@@ -20,255 +23,260 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
public class Gardening { public class Gardening {
public static Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>(); public static Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>(); public static Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>();
public static Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>(); public static Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>();
public static boolean isSoil(Block block) { public static boolean isSoil(Block block) {
return block instanceof IBlockSoil; return block instanceof IBlockSoil;
} }
public static boolean isSoil(Item item) { public static boolean isSoil(Item item) {
return item instanceof ItemBlock return item instanceof ItemBlock && isSoil(((ItemBlock) item).field_150939_a);
&& isSoil(((ItemBlock) item).field_150939_a); }
}
public static EnumMoisture getNaturalMoisture(World world, int x, int y, int z) { public static EnumMoisture getNaturalMoisture(World world, int x, int y, int z) {
float bias = getBiomeMoisture(world.getBiomeGenForCoords(x, z), y); float bias = getBiomeMoisture(world.getBiomeGenForCoords(x, z), y);
for (int dx = -1; dx < 2; ++dx) { for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) { for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) { if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.sand) { if (world.getBlock(x + dx, y, z + dz) == Blocks.sand) {
bias -= 1.5; bias -= 1.5;
} else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) { } else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) {
bias += 1.5; bias += 1.5;
} }
} }
} }
} }
if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) { if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) {
bias += 1.5; bias += 1.5;
} }
for (int dx = -1; dx < 2; ++dx) { for (int dx = -1; dx < 2; ++dx) {
for (int dz = -1; dz < 2; ++dz) { for (int dz = -1; dz < 2; ++dz) {
if (dx != 0 || dz != 0) { if (dx != 0 || dz != 0) {
if (world.getBlock(x + dx, y, z + dz) == Blocks.gravel && bias > 0.0f) { if (world.getBlock(x + dx, y, z + dz) == Blocks.gravel && bias > 0.0f) {
bias *= 0.4f; bias *= 0.4f;
} }
} }
} }
} }
if (bias <= -1.0f) { if (bias <= -1.0f) {
return EnumMoisture.DRY; return EnumMoisture.DRY;
} }
return (bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL; return (bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL;
} }
public static EnumAcidity getNaturalPH(World world, int x, int y, int z) { public static EnumAcidity getNaturalPH(World world, int x, int y, int z) {
float bias = getBiomePH(world.getBiomeGenForCoords(x, z), y); float bias = getBiomePH(world.getBiomeGenForCoords(x, z), y);
if (bias <= -1.0f) { if (bias <= -1.0f) {
return EnumAcidity.ACID; return EnumAcidity.ACID;
} }
return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL; return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL;
} }
public static float getBiomeMoisture(BiomeGenBase biome, int H) { public static float getBiomeMoisture(BiomeGenBase biome, int H) {
double R = biome.rainfall; double R = biome.rainfall;
double T = biome.temperature; double T = biome.temperature;
double m = 3.2 * (R - 0.5) - 0.4 * (1.0 + T + 0.5 * T * T) + 1.1 - 1.6 * (T - 0.9) * (T - 0.9) - 0.002 * (H - 64); double m =
if (m == 0.0) { 3.2 * (R - 0.5) - 0.4 * (1.0 + T + 0.5 * T * T) + 1.1 - 1.6 * (T - 0.9) * (T - 0.9) - 0.002 * (H - 64);
return (float) m; if (m == 0.0) {
} return (float) m;
if (m < 0.0){ }
return (float) -Math.sqrt(m * m); if (m < 0.0) {
} return (float) -Math.sqrt(m * m);
return (float) Math.sqrt(m * m); }
} return (float) Math.sqrt(m * m);
}
public static float getBiomePH(BiomeGenBase biome, int H) { public static float getBiomePH(BiomeGenBase biome, int H) {
double R = biome.rainfall; double R = biome.rainfall;
double T = biome.temperature; double T = biome.temperature;
return (float) (-3.0 * (R - 0.5) + 0.5 * (T - 0.699999988079071) * (T - 0.699999988079071) + 0.02f * (H - 64) - 0.15000000596046448); return (float) (-3.0 * (R - 0.5)
} + 0.5 * (T - 0.699999988079071) * (T - 0.699999988079071)
+ 0.02f * (H - 64)
- 0.15000000596046448);
}
public static void createSoil(World world, int x, int y, int z, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) { public static void createSoil(
int meta = moisture.ordinal() + acidity.ordinal() * 3; World world, int x, int y, int z, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
world.setBlock(x, y, z, getSoilBlock(soil), meta, 2); int meta = moisture.ordinal() + acidity.ordinal() * 3;
} world.setBlock(x, y, z, getSoilBlock(soil), meta, 2);
}
public static boolean plant(World world, int x, int y, int z, IFlower flower, GameProfile owner) { public static boolean plant(World world, int x, int y, int z, IFlower flower, GameProfile owner) {
boolean set = world.setBlock(x, y, z, Botany.flower, 0, 2); boolean set = world.setBlock(x, y, z, Botany.flower, 0, 2);
if (!set) { if (!set) {
return false; return false;
} }
TileEntity tileFlower = world.getTileEntity(x, y, z); TileEntity tileFlower = world.getTileEntity(x, y, z);
TileEntity below = world.getTileEntity(x, y - 1, z); TileEntity below = world.getTileEntity(x, y - 1, z);
if (tileFlower != null && tileFlower instanceof TileEntityFlower) { if (tileFlower != null && tileFlower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) { if (below instanceof TileEntityFlower) {
((TileEntityFlower) tileFlower).setSection(((TileEntityFlower) below).getSection()); ((TileEntityFlower) tileFlower).setSection(((TileEntityFlower) below).getSection());
} else { } else {
((TileEntityFlower) tileFlower).create(flower, owner); ((TileEntityFlower) tileFlower).create(flower, owner);
} }
} }
tryGrowSection(world, x, y, z); tryGrowSection(world, x, y, z);
return true; return true;
} }
public static void tryGrowSection(World world, int x, int y, int z) { public static void tryGrowSection(World world, int x, int y, int z) {
if (!BinnieCore.proxy.isSimulating(world)) { if (!BinnieCore.proxy.isSimulating(world)) {
return; return;
} }
TileEntity flower = world.getTileEntity(x, y, z); TileEntity flower = world.getTileEntity(x, y, z);
if (flower == null || !(flower instanceof TileEntityFlower)) { if (flower == null || !(flower instanceof TileEntityFlower)) {
return; return;
} }
IFlower iflower = ((TileEntityFlower) flower).getFlower(); IFlower iflower = ((TileEntityFlower) flower).getFlower();
int section = ((TileEntityFlower) flower).getSection(); int section = ((TileEntityFlower) flower).getSection();
if (iflower == null || section >= iflower.getGenome().getPrimary().getType().getSections() - 1 || iflower.getAge() <= 0) { if (iflower == null
return; || section >= iflower.getGenome().getPrimary().getType().getSections() - 1
} || iflower.getAge() <= 0) {
return;
}
world.setBlock(x, y + 1, z, Botany.flower, 0, 2); world.setBlock(x, y + 1, z, Botany.flower, 0, 2);
TileEntity tileFlower = world.getTileEntity(x, y + 1, z); TileEntity tileFlower = world.getTileEntity(x, y + 1, z);
if (tileFlower != null && tileFlower instanceof TileEntityFlower) { if (tileFlower != null && tileFlower instanceof TileEntityFlower) {
((TileEntityFlower) tileFlower).setSection(section + 1); ((TileEntityFlower) tileFlower).setSection(section + 1);
} }
} }
public static void onGrowFromSeed(World world, int x, int y, int z) { public static void onGrowFromSeed(World world, int x, int y, int z) {
tryGrowSection(world, x, y, z); tryGrowSection(world, x, y, z);
} }
public static Collection<ItemStack> getAcidFertilisers() { public static Collection<ItemStack> getAcidFertilisers() {
return Gardening.fertiliserAcid.keySet(); return Gardening.fertiliserAcid.keySet();
} }
public static Collection<ItemStack> getAlkalineFertilisers() { public static Collection<ItemStack> getAlkalineFertilisers() {
return Gardening.fertiliserAlkaline.keySet(); return Gardening.fertiliserAlkaline.keySet();
} }
public static Collection<ItemStack> getNutrientFertilisers() { public static Collection<ItemStack> getNutrientFertilisers() {
return Gardening.fertiliserNutrient.keySet(); return Gardening.fertiliserNutrient.keySet();
} }
public static boolean isAcidFertiliser(ItemStack itemstack) { public static boolean isAcidFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAcidFertilisers()) { for (ItemStack stack : getAcidFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) { if (stack != null && stack.isItemEqual(itemstack)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean isAlkalineFertiliser(ItemStack itemstack) { public static boolean isAlkalineFertiliser(ItemStack itemstack) {
for (ItemStack stack : getAlkalineFertilisers()) { for (ItemStack stack : getAlkalineFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) { if (stack != null && stack.isItemEqual(itemstack)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean isNutrientFertiliser(ItemStack itemstack) { public static boolean isNutrientFertiliser(ItemStack itemstack) {
for (ItemStack stack : getNutrientFertilisers()) { for (ItemStack stack : getNutrientFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) { if (stack != null && stack.isItemEqual(itemstack)) {
return true; return true;
} }
} }
return false; return false;
} }
public static int getFertiliserStrength(ItemStack stack) { public static int getFertiliserStrength(ItemStack stack) {
if (stack == null) { if (stack == null) {
return 1; return 1;
} }
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAcid.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAcid.entrySet()) {
if (entry.getKey().isItemEqual(stack)) { if (entry.getKey().isItemEqual(stack)) {
return entry.getValue(); return entry.getValue();
} }
} }
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAlkaline.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserAlkaline.entrySet()) {
if (entry.getKey().isItemEqual(stack)) { if (entry.getKey().isItemEqual(stack)) {
return entry.getValue(); return entry.getValue();
} }
} }
for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserNutrient.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : Gardening.fertiliserNutrient.entrySet()) {
if (entry.getKey().isItemEqual(stack)) { if (entry.getKey().isItemEqual(stack)) {
return entry.getValue(); return entry.getValue();
} }
} }
return 1; return 1;
} }
public static boolean canTolerate(IFlower flower, World world, int x, int y, int z) { public static boolean canTolerate(IFlower flower, World world, int x, int y, int z) {
if (flower == null || flower.getGenome() == null) { if (flower == null || flower.getGenome() == null) {
return false; return false;
} }
int soilMeta = world.getBlockMetadata(x, y - 1, z); int soilMeta = world.getBlockMetadata(x, y - 1, z);
BiomeGenBase biome = world.getBiomeGenForCoords(x, z); BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.temperature)); return canTolerate(
} flower,
EnumAcidity.values()[soilMeta / 3 % 3],
EnumMoisture.values()[soilMeta % 3],
EnumTemperature.getFromValue(biome.temperature));
}
public static EnumSoilType getSoilType(World world, int x, int y, int z) { public static EnumSoilType getSoilType(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) instanceof IBlockSoil) { if (world.getBlock(x, y, z) instanceof IBlockSoil) {
return ((IBlockSoil) world.getBlock(x, y, z)).getType(world, x, y, z); return ((IBlockSoil) world.getBlock(x, y, z)).getType(world, x, y, z);
} }
return EnumSoilType.SOIL; return EnumSoilType.SOIL;
} }
public static Block getSoilBlock(EnumSoilType type) { public static Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false); return getSoilBlock(type, false);
} }
public static Block getSoilBlock(EnumSoilType type, boolean weedkill) { public static Block getSoilBlock(EnumSoilType type, boolean weedkill) {
switch (type) { switch (type) {
case FLOWERBED: case FLOWERBED:
return weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed; return weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed;
case LOAM: case LOAM:
return weedkill ? Botany.loamNoWeed : Botany.loam; return weedkill ? Botany.loamNoWeed : Botany.loam;
} }
return weedkill ? Botany.soilNoWeed : Botany.soil; return weedkill ? Botany.soilNoWeed : Botany.soil;
} }
public static boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) { public static boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) {
return flower.getGenome().canTolerate(ePH) return flower.getGenome().canTolerate(ePH)
&& flower.getGenome().canTolerate(eMoisture) && flower.getGenome().canTolerate(eMoisture)
&& flower.getGenome().canTolerate(eTemp); && flower.getGenome().canTolerate(eTemp);
} }
public static boolean isWeedkiller(ItemStack heldItem) { public static boolean isWeedkiller(ItemStack heldItem) {
return heldItem != null return heldItem != null && heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
&& heldItem.isItemEqual(BotanyItems.Weedkiller.get(1)); }
}
public static boolean addWeedKiller(World world, int x, int y, int z) { public static boolean addWeedKiller(World world, int x, int y, int z) {
if (!(world.getBlock(x, y, z) instanceof IBlockSoil)) { if (!(world.getBlock(x, y, z) instanceof IBlockSoil)) {
return false; return false;
} }
EnumSoilType type = getSoilType(world, x, y, z); EnumSoilType type = getSoilType(world, x, y, z);
Block block = getSoilBlock(type, true); Block block = getSoilBlock(type, true);
boolean done = world.setBlock(x, y, z, block, world.getBlockMetadata(x, y, z), 2); boolean done = world.setBlock(x, y, z, block, world.getBlockMetadata(x, y, z), 2);
if (done && BlockPlant.isWeed(world, x, y + 1, z)) { if (done && BlockPlant.isWeed(world, x, y + 1, z)) {
world.setBlockToAir(x, y + 1, z); world.setBlockToAir(x, y + 1, z);
} }
return done; return done;
} }
} }
@@ -6,81 +6,72 @@ import binnie.botany.api.EnumSoilType;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Locale;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import java.util.List;
import java.util.Locale;
public class ItemSoil extends ItemBlock { public class ItemSoil extends ItemBlock {
protected EnumSoilType type; protected EnumSoilType type;
private boolean noWeed; private boolean noWeed;
public ItemSoil(Block block) { public ItemSoil(Block block) {
super(block); super(block);
type = ((BlockSoil) field_150939_a).getType(); type = ((BlockSoil) field_150939_a).getType();
noWeed = ((BlockSoil) field_150939_a).weedKilled; noWeed = ((BlockSoil) field_150939_a).weedKilled;
hasSubtypes = true; hasSubtypes = true;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
EnumMoisture moisture = EnumMoisture.values()[stack.getItemDamage() % 3]; EnumMoisture moisture = EnumMoisture.values()[stack.getItemDamage() % 3];
EnumAcidity acidity = EnumAcidity.values()[stack.getItemDamage() / 3]; EnumAcidity acidity = EnumAcidity.values()[stack.getItemDamage() / 3];
String info = ""; String info = "";
if (moisture == EnumMoisture.DRY) { if (moisture == EnumMoisture.DRY) {
info += EnumChatFormatting.YELLOW info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.dry") + EnumChatFormatting.RESET;
+ I18N.localise("botany.moisture.dry") }
+ EnumChatFormatting.RESET; if (moisture == EnumMoisture.DAMP) {
} info += EnumChatFormatting.YELLOW + I18N.localise("botany.moisture.damp") + EnumChatFormatting.RESET;
if (moisture == EnumMoisture.DAMP) { }
info += EnumChatFormatting.YELLOW
+ I18N.localise("botany.moisture.damp")
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ACID) { if (acidity == EnumAcidity.ACID) {
if (info.length() > 0) { if (info.length() > 0) {
info += ", "; info += ", ";
} }
info += EnumChatFormatting.YELLOW info += EnumChatFormatting.YELLOW + I18N.localise("botany.ph.acid") + EnumChatFormatting.RESET;
+ I18N.localise("botany.ph.acid") }
+ EnumChatFormatting.RESET;
}
if (acidity == EnumAcidity.ALKALINE) { if (acidity == EnumAcidity.ALKALINE) {
if (info.length() > 0) { if (info.length() > 0) {
info += ", "; info += ", ";
} }
info += EnumChatFormatting.YELLOW info += EnumChatFormatting.YELLOW + I18N.localise("botany.ph.alkaline") + EnumChatFormatting.RESET;
+ I18N.localise("botany.ph.alkaline") }
+ EnumChatFormatting.RESET;
}
if (info.length() > 0) { if (info.length() > 0) {
tooltip.add(info); tooltip.add(info);
} }
if (noWeed) { if (noWeed) {
tooltip.add(I18N.localise("botany.soil.weedkiller")); tooltip.add(I18N.localise("botany.soil.weedkiller"));
} }
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
String soilName = type.name().toLowerCase(Locale.ENGLISH); String soilName = type.name().toLowerCase(Locale.ENGLISH);
return I18N.localise("botany.soil." + soilName); return I18N.localise("botany.soil." + soilName);
} }
@Override @Override
public int getMetadata(int meta) { public int getMetadata(int meta) {
return meta; return meta;
} }
} }
@@ -22,63 +22,67 @@ import net.minecraft.util.IChatComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemSoilMeter extends Item { public class ItemSoilMeter extends Item {
public ItemSoilMeter() { public ItemSoilMeter() {
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("soilMeter"); setUnlocalizedName("soilMeter");
setMaxStackSize(1); setMaxStackSize(1);
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float blockX, float blockY, float blockZ) { public boolean onItemUse(
Block block = world.getBlock(x, y, z); ItemStack stack,
if (!Gardening.isSoil(block)) { EntityPlayer player,
y--; World world,
block = world.getBlock(x, y, z); int x,
} int y,
int z,
int side,
float blockX,
float blockY,
float blockZ) {
Block block = world.getBlock(x, y, z);
if (!Gardening.isSoil(block)) {
y--;
block = world.getBlock(x, y, z);
}
if (Gardening.isSoil(block) && !BinnieCore.proxy.isSimulating(world)) { if (Gardening.isSoil(block) && !BinnieCore.proxy.isSimulating(world)) {
IBlockSoil soil = (IBlockSoil) block; IBlockSoil soil = (IBlockSoil) block;
EnumSoilType type = soil.getType(world, x, y, z); EnumSoilType type = soil.getType(world, x, y, z);
EnumMoisture moisture = soil.getMoisture(world, x, y, z); EnumMoisture moisture = soil.getMoisture(world, x, y, z);
EnumAcidity pH = soil.getPH(world, x, y, z); EnumAcidity pH = soil.getPH(world, x, y, z);
EnumChatFormatting[] colors = new EnumChatFormatting[]{ EnumChatFormatting[] colors = new EnumChatFormatting[] {
EnumChatFormatting.DARK_GRAY, EnumChatFormatting.DARK_GRAY, EnumChatFormatting.GOLD, EnumChatFormatting.LIGHT_PURPLE,
EnumChatFormatting.GOLD, };
EnumChatFormatting.LIGHT_PURPLE, String info = I18N.localise("botany.soil.tooltip.type") + " ";
}; info += colors[type.ordinal()] + AlleleHelper.toDisplay(type) + EnumChatFormatting.RESET;
String info = I18N.localise("botany.soil.tooltip.type") + " ";
info += colors[type.ordinal()] + AlleleHelper.toDisplay(type) + EnumChatFormatting.RESET;
colors = new EnumChatFormatting[]{ colors = new EnumChatFormatting[] {
EnumChatFormatting.YELLOW, EnumChatFormatting.YELLOW, EnumChatFormatting.GRAY, EnumChatFormatting.BLUE,
EnumChatFormatting.GRAY, };
EnumChatFormatting.BLUE, info += ", " + I18N.localise("botany.soil.tooltip.moisture") + " ";
}; info += colors[moisture.ordinal()] + AlleleHelper.toDisplay(moisture) + EnumChatFormatting.RESET;
info += ", " + I18N.localise("botany.soil.tooltip.moisture") + " ";
info += colors[moisture.ordinal()] + AlleleHelper.toDisplay(moisture) + EnumChatFormatting.RESET;
colors = new EnumChatFormatting[]{ colors = new EnumChatFormatting[] {
EnumChatFormatting.RED, EnumChatFormatting.RED, EnumChatFormatting.GREEN, EnumChatFormatting.AQUA,
EnumChatFormatting.GREEN, };
EnumChatFormatting.AQUA, info += ", " + I18N.localise("botany.soil.tooltip.pH") + " ";
}; info += colors[pH.ordinal()] + AlleleHelper.toDisplay(pH) + EnumChatFormatting.RESET;
info += ", " + I18N.localise("botany.soil.tooltip.pH") + " "; IChatComponent chat = new ChatComponentText(info);
info += colors[pH.ordinal()] + AlleleHelper.toDisplay(pH) + EnumChatFormatting.RESET; player.addChatMessage(chat);
IChatComponent chat = new ChatComponentText(info); }
player.addChatMessage(chat); return super.onItemUse(stack, player, world, x, y, z, side, blockX, blockY, blockZ);
} }
return super.onItemUse(stack, player, world, x, y, z, side, blockX, blockY, blockZ);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "soilMeter"); itemIcon = Botany.proxy.getIcon(register, "soilMeter");
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.soilMeter.name"); return I18N.localise("botany.item.soilMeter.name");
} }
} }
@@ -16,52 +16,69 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemTrowel extends Item { public class ItemTrowel extends Item {
protected Item.ToolMaterial theToolMaterial; protected Item.ToolMaterial theToolMaterial;
String locName; String locName;
public ItemTrowel(Item.ToolMaterial toolMaterial, String material) { public ItemTrowel(Item.ToolMaterial toolMaterial, String material) {
theToolMaterial = toolMaterial; theToolMaterial = toolMaterial;
maxStackSize = 1; maxStackSize = 1;
setMaxDamage(toolMaterial.getMaxUses()); setMaxDamage(toolMaterial.getMaxUses());
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("trowel" + material); setUnlocalizedName("trowel" + material);
locName = "trowel" + material; locName = "trowel" + material;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "tools/" + locName); itemIcon = Botany.proxy.getIcon(register, "tools/" + locName);
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float blockX, float blockY, float blockZ) { public boolean onItemUse(
if (!player.canPlayerEdit(x, y, z, side, stack)) { ItemStack stack,
return false; EntityPlayer player,
} World world,
Block block = world.getBlock(x, y, z); int x,
if (side == 0 || int y,
(!world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && world.getBlock(x, y + 1, z) != Botany.flower) || int z,
(block != Blocks.grass && block != Blocks.dirt)) { int side,
return false; float blockX,
} float blockY,
float blockZ) {
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}
Block block = world.getBlock(x, y, z);
if (side == 0
|| (!world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
&& world.getBlock(x, y + 1, z) != Botany.flower)
|| (block != Blocks.grass && block != Blocks.dirt)) {
return false;
}
Block block2 = Botany.soil; Block block2 = Botany.soil;
world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, block2.stepSound.getStepResourcePath(), (block2.stepSound.getVolume() + 1.0f) / 2.0f, block2.stepSound.getPitch() * 0.8f); world.playSoundEffect(
if (world.isRemote) { x + 0.5f,
return true; y + 0.5f,
} z + 0.5f,
block2.stepSound.getStepResourcePath(),
(block2.stepSound.getVolume() + 1.0f) / 2.0f,
block2.stepSound.getPitch() * 0.8f);
if (world.isRemote) {
return true;
}
EnumMoisture moisture = Gardening.getNaturalMoisture(world, x, y, z); EnumMoisture moisture = Gardening.getNaturalMoisture(world, x, y, z);
EnumAcidity acidity = Gardening.getNaturalPH(world, x, y, z); EnumAcidity acidity = Gardening.getNaturalPH(world, x, y, z);
Gardening.createSoil(world, x, y, z, EnumSoilType.SOIL, moisture, acidity); Gardening.createSoil(world, x, y, z, EnumSoilType.SOIL, moisture, acidity);
stack.damageItem(1, player); stack.damageItem(1, player);
return true; return true;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean isFull3D() { public boolean isFull3D() {
return true; return true;
} }
} }
@@ -8,25 +8,25 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
public class ItemWeed extends ItemBlock { public class ItemWeed extends ItemBlock {
public ItemWeed(Block block) { public ItemWeed(Block block) {
super(block); super(block);
setHasSubtypes(true); setHasSubtypes(true);
hasSubtypes = true; hasSubtypes = true;
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return BlockPlant.Type.values()[stack.getItemDamage()].getName(); return BlockPlant.Type.values()[stack.getItemDamage()].getName();
} }
@Override @Override
public int getMetadata(int meta) { public int getMetadata(int meta) {
return meta; return meta;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) { public IIcon getIconFromDamage(int damage) {
return field_150939_a.getIcon(2, damage); return field_150939_a.getIcon(2, damage);
} }
} }
@@ -26,6 +26,8 @@ import binnie.core.block.ItemMetadataRenderer;
import binnie.core.block.MultipassItemRenderer; import binnie.core.block.MultipassItemRenderer;
import binnie.core.block.TileEntityMetadata; import binnie.core.block.TileEntityMetadata;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@@ -35,336 +37,317 @@ import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.HashMap;
import java.util.Map;
public class ModuleGardening implements IInitializable { public class ModuleGardening implements IInitializable {
public static HashMap<ItemStack, Integer> queuedAcidFertilisers = new HashMap<>(); public static HashMap<ItemStack, Integer> queuedAcidFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>(); public static HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>();
public static HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>(); public static HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>();
@Override @Override
public void preInit() { public void preInit() {
Botany.plant = new BlockPlant(); Botany.plant = new BlockPlant();
GameRegistry.registerBlock(Botany.plant, ItemWeed.class, "plant"); GameRegistry.registerBlock(Botany.plant, ItemWeed.class, "plant");
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false); Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
GameRegistry.registerBlock(Botany.soil, ItemSoil.class, "soil"); GameRegistry.registerBlock(Botany.soil, ItemSoil.class, "soil");
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false); Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
GameRegistry.registerBlock(Botany.loam, ItemSoil.class, "loam"); GameRegistry.registerBlock(Botany.loam, ItemSoil.class, "loam");
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false); Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
GameRegistry.registerBlock(Botany.flowerbed, ItemSoil.class, "flowerbed"); GameRegistry.registerBlock(Botany.flowerbed, ItemSoil.class, "flowerbed");
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soilNoWeed", true); Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soilNoWeed", true);
GameRegistry.registerBlock(Botany.soilNoWeed, ItemSoil.class, "soilNoWeed"); GameRegistry.registerBlock(Botany.soilNoWeed, ItemSoil.class, "soilNoWeed");
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loamNoWeed", true); Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loamNoWeed", true);
GameRegistry.registerBlock(Botany.loamNoWeed, ItemSoil.class, "loamNoWeed"); GameRegistry.registerBlock(Botany.loamNoWeed, ItemSoil.class, "loamNoWeed");
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbedNoWeed", true); Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbedNoWeed", true);
GameRegistry.registerBlock(Botany.flowerbedNoWeed, ItemSoil.class, "flowerbedNoWeed"); GameRegistry.registerBlock(Botany.flowerbedNoWeed, ItemSoil.class, "flowerbedNoWeed");
Botany.soilMeter = new ItemSoilMeter(); Botany.soilMeter = new ItemSoilMeter();
Botany.insulatedTube = new ItemInsulatedTube(); Botany.insulatedTube = new ItemInsulatedTube();
Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "Wood"); Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "Wood");
Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "Stone"); Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "Stone");
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "Iron"); Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "Iron");
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.EMERALD, "Diamond"); Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.EMERALD, "Diamond");
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "Gold"); Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "Gold");
Botany.misc = Binnie.Item.registerMiscItems(BotanyItems.values(), CreativeTabBotany.instance); Botany.misc = Binnie.Item.registerMiscItems(BotanyItems.values(), CreativeTabBotany.instance);
Botany.pigment = new ItemPigment(); Botany.pigment = new ItemPigment();
Botany.clay = new ItemClay(); Botany.clay = new ItemClay();
Botany.ceramic = new BlockCeramic(); Botany.ceramic = new BlockCeramic();
GameRegistry.registerBlock(Botany.ceramic, ItemMetadata.class, "ceramic"); GameRegistry.registerBlock(Botany.ceramic, ItemMetadata.class, "ceramic");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer()); BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
Botany.stained = new BlockStained(); Botany.stained = new BlockStained();
GameRegistry.registerBlock(Botany.stained, ItemMetadata.class, "stained"); GameRegistry.registerBlock(Botany.stained, ItemMetadata.class, "stained");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer()); BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
Botany.ceramicTile = new BlockCeramicPatterned(); Botany.ceramicTile = new BlockCeramicPatterned();
GameRegistry.registerBlock(Botany.ceramicTile, ItemMetadata.class, "ceramicPattern"); GameRegistry.registerBlock(Botany.ceramicTile, ItemMetadata.class, "ceramicPattern");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer()); BinnieCore.proxy.registerCustomItemRenderer(
Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
Botany.ceramicBrick = new BlockCeramicBrick(); Botany.ceramicBrick = new BlockCeramicBrick();
GameRegistry.registerBlock(Botany.ceramicBrick, ItemMetadata.class, "ceramicBrick"); GameRegistry.registerBlock(Botany.ceramicBrick, ItemMetadata.class, "ceramicBrick");
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer()); BinnieCore.proxy.registerCustomItemRenderer(
} Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
}
@Override @Override
public void init() { public void init() {
OreDictionary.registerOre("pigment", Botany.pigment); OreDictionary.registerOre("pigment", Botany.pigment);
RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, ""); RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, "");
RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, ""); RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, "");
ItemStack yellow = new ItemStack(Blocks.yellow_flower, 1); ItemStack yellow = new ItemStack(Blocks.yellow_flower, 1);
ItemStack red = new ItemStack(Blocks.red_flower, 1); ItemStack red = new ItemStack(Blocks.red_flower, 1);
ItemStack blue = new ItemStack(Blocks.red_flower, 1, 7); ItemStack blue = new ItemStack(Blocks.red_flower, 1, 7);
for (boolean manual : new boolean[]{true, false}) { for (boolean manual : new boolean[] {true, false}) {
for (boolean fertilised : new boolean[]{true, false}) { for (boolean fertilised : new boolean[] {true, false}) {
for (EnumMoisture moist : EnumMoisture.values()) { for (EnumMoisture moist : EnumMoisture.values()) {
ItemStack icon = (moist == EnumMoisture.DRY) ? yellow : ((moist == EnumMoisture.NORMAL) ? red : blue); ItemStack icon =
int insulate = 2 - moist.ordinal(); (moist == EnumMoisture.DRY) ? yellow : ((moist == EnumMoisture.NORMAL) ? red : blue);
if (fertilised) { int insulate = 2 - moist.ordinal();
insulate += 3; if (fertilised) {
} insulate += 3;
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 128 * insulate), icon); }
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate), icon); new CircuitGarden(
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate), icon); moist,
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate), icon); null,
} manual,
} fertilised,
} new ItemStack(Botany.insulatedTube, 1, 128 * insulate),
} icon);
new CircuitGarden(
moist,
EnumAcidity.ACID,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate),
icon);
new CircuitGarden(
moist,
EnumAcidity.NEUTRAL,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate),
icon);
new CircuitGarden(
moist,
EnumAcidity.ALKALINE,
manual,
fertilised,
new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate),
icon);
}
}
}
}
@Override @Override
public void postInit() { public void postInit() {
GameRegistry.addRecipe(new CeramicTileRecipe()); GameRegistry.addRecipe(new CeramicTileRecipe());
for (int mat = 0; mat < 4; ++mat) { for (int mat = 0; mat < 4; ++mat) {
for (int insulate = 0; insulate < 6; ++insulate) { for (int insulate = 0; insulate < 6; ++insulate) {
ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate); ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes); ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
ItemStack forestryTube = new ItemStack(Mods.forestry.item("thermionicTubes"), 1, mat); ItemStack forestryTube = new ItemStack(Mods.forestry.item("thermionicTubes"), 1, mat);
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack); GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
} }
} }
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.soil, 1, OreDictionary.WILDCARD_VALUE)); GameRegistry.addShapelessRecipe(
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.loam, 1, OreDictionary.WILDCARD_VALUE)); new ItemStack(Blocks.dirt), new ItemStack(Botany.soil, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbed, 1, OreDictionary.WILDCARD_VALUE)); GameRegistry.addShapelessRecipe(
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.soilNoWeed, 1, OreDictionary.WILDCARD_VALUE)); new ItemStack(Blocks.dirt), new ItemStack(Botany.loam, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.loamNoWeed, 1, OreDictionary.WILDCARD_VALUE)); GameRegistry.addShapelessRecipe(
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbedNoWeed, 1, OreDictionary.WILDCARD_VALUE)); new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt), new ItemStack(Botany.soilNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt), new ItemStack(Botany.loamNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(
new ItemStack(Blocks.dirt), new ItemStack(Botany.flowerbedNoWeed, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addRecipe(new ShapedOreRecipe( GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelWood, Botany.trowelWood,
new Object[]{ new Object[] {"d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "plankWood"}));
"d ", " x ", " s", GameRegistry.addRecipe(new ShapedOreRecipe(
'd', Blocks.dirt, Botany.trowelStone,
's', "stickWood", new Object[] {"d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "cobblestone"}));
'x', "plankWood" GameRegistry.addRecipe(new ShapedOreRecipe(
} Botany.trowelIron,
)); new Object[] {"d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "ingotIron"}));
GameRegistry.addRecipe(new ShapedOreRecipe( GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelStone, Botany.trowelGold,
new Object[]{ new Object[] {"d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "ingotGold"}));
"d ", " x ", " s", GameRegistry.addRecipe(new ShapedOreRecipe(
'd', Blocks.dirt, Botany.trowelDiamond,
's', "stickWood", new Object[] {"d ", " x ", " s", 'd', Blocks.dirt, 's', "stickWood", 'x', "gemDiamond"}));
'x', "cobblestone" GameRegistry.addRecipe(new ShapedOreRecipe(
} Botany.soilMeter,
)); new Object[] {" gg", " rg", "i ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron"}));
GameRegistry.addRecipe(new ShapedOreRecipe( GameRegistry.addShapelessRecipe(
Botany.trowelIron, BotanyItems.Weedkiller.get(4),
new Object[]{ new ItemStack(Items.spider_eye),
"d ", " x ", " s", new ItemStack(Items.wheat_seeds),
'd', Blocks.dirt, new ItemStack(Items.wheat_seeds),
's', "stickWood", new ItemStack(Items.wheat_seeds));
'x', "ingotIron"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelGold,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "ingotGold"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.trowelDiamond,
new Object[]{
"d ", " x ", " s",
'd', Blocks.dirt,
's', "stickWood",
'x', "gemDiamond"
}
));
GameRegistry.addRecipe(new ShapedOreRecipe(
Botany.soilMeter,
new Object[]{
" gg", " rg", "i ",
'g', "ingotGold",
'r', "dustRedstone",
'i', "ingotIron"
}
));
GameRegistry.addShapelessRecipe(
BotanyItems.Weedkiller.get(4),
new ItemStack(Items.spider_eye),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds),
new ItemStack(Items.wheat_seeds)
);
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.forestry.stack("ash")); GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.forestry.stack("ash"));
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.forestry.stack("mulch")); GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.forestry.stack("mulch"));
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.forestry.stack("fertilizerBio")); GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.forestry.stack("fertilizerBio"));
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.forestry.stack("fertilizerCompound")); GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.forestry.stack("fertilizerCompound"));
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.forestry.stack("woodPulp")); GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.forestry.stack("woodPulp"));
GameRegistry.addRecipe(new ShapelessOreRecipe( GameRegistry.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), new Object[] {"dustSulphur"}));
BotanyItems.SulphurPowder.get(4),
new Object[]{"dustSulphur"}
));
GameRegistry.addRecipe(new ShapelessOreRecipe( GameRegistry.addRecipe(new ShapelessOreRecipe(
new ItemStack(Botany.pigment, 2, EnumFlowerColor.BLACK.ordinal()), new ItemStack(Botany.pigment, 2, EnumFlowerColor.BLACK.ordinal()),
new Object[]{ new Object[] {"pigment", "pigment", "dyeBlack"}));
"pigment",
"pigment",
"dyeBlack"
}
));
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1); ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1); ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "mulch")), 2); ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "mulch")), 2);
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) { for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
ModuleGardening.queuedAcidFertilisers.put(stack, 2); ModuleGardening.queuedAcidFertilisers.put(stack, 2);
} }
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1); ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1); ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "ash")), 2); ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "ash")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "woodPulp")), 2); ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "woodPulp")), 2);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1); ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1); ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerBio")), 2); ModuleGardening.queuedNutrientFertilisers.put(
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("Forestry", "fertilizerCompound")), 2); new ItemStack(GameRegistry.findItem("Forestry", "fertilizerBio")), 2);
ModuleGardening.queuedNutrientFertilisers.put(
new ItemStack(GameRegistry.findItem("Forestry", "fertilizerCompound")), 2);
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
addAcidFertiliser(entry.getKey(), entry.getValue()); addAcidFertiliser(entry.getKey(), entry.getValue());
} }
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
addAlkalineFertiliser(entry.getKey(), entry.getValue()); addAlkalineFertiliser(entry.getKey(), entry.getValue());
} }
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) { for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
addNutrientFertiliser(entry.getKey(), entry.getValue()); addNutrientFertiliser(entry.getKey(), entry.getValue());
} }
GameRegistry.addRecipe( GameRegistry.addRecipe(
BotanyItems.Mortar.get(6), BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.clay_ball, 'g', Blocks.gravel);
" c ", "cgc", " c ",
'c', Items.clay_ball,
'g', Blocks.gravel
);
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal()); ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal()); ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment); GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment);
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f); GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f);
ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal()); ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
glass.stackSize = 4; glass.stackSize = 4;
GameRegistry.addShapedRecipe( GameRegistry.addShapedRecipe(glass, " g ", "gpg", " g ", 'g', Blocks.glass, 'p', pigment);
glass, }
" g ", "gpg", " g ",
'g', Blocks.glass,
'p', pigment
);
}
GameRegistry.addRecipe(new PigmentRecipe()); GameRegistry.addRecipe(new PigmentRecipe());
} }
private ItemStack getStack(int type, int pH, int moisture) { private ItemStack getStack(int type, int pH, int moisture) {
if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) { if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) {
return null; return null;
} }
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture])); return new ItemStack(
} Gardening.getSoilBlock(EnumSoilType.values()[type]),
1,
BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
}
private void addAcidFertiliser(ItemStack stack, int strengthMax) { private void addAcidFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) { if (stack == null) {
return; return;
} }
Gardening.fertiliserAcid.put(stack, strengthMax); Gardening.fertiliserAcid.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) { for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) { for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) { for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax; int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) { for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture); ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH - strength, moisture); ItemStack end = getStack(type, pH - strength, moisture);
if (end != null) { if (end != null) {
end.stackSize = numOfBlocks; end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1]; Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) { for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start; stacks[i] = start;
} }
stacks[numOfBlocks] = stack.copy(); stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks); GameRegistry.addShapelessRecipe(end, stacks);
} }
numOfBlocks /= 2; numOfBlocks /= 2;
} }
} }
} }
} }
} }
private void addAlkalineFertiliser(ItemStack stack, int strengthMax) { private void addAlkalineFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) { if (stack == null) {
return; return;
} }
Gardening.fertiliserAlkaline.put(stack, strengthMax); Gardening.fertiliserAlkaline.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) { for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) { for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) { for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax; int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) { for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture); ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type, pH + strength, moisture); ItemStack end = getStack(type, pH + strength, moisture);
if (end != null) { if (end != null) {
end.stackSize = numOfBlocks; end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1]; Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) { for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start; stacks[i] = start;
} }
stacks[numOfBlocks] = stack.copy(); stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks); GameRegistry.addShapelessRecipe(end, stacks);
} }
numOfBlocks /= 2; numOfBlocks /= 2;
} }
} }
} }
} }
} }
private void addNutrientFertiliser(ItemStack stack, int strengthMax) { private void addNutrientFertiliser(ItemStack stack, int strengthMax) {
if (stack == null) { if (stack == null) {
return; return;
} }
Gardening.fertiliserNutrient.put(stack, strengthMax); Gardening.fertiliserNutrient.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) { for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) { for (int pH = 0; pH < 3; ++pH) {
for (int type = 0; type < 3; ++type) { for (int type = 0; type < 3; ++type) {
int numOfBlocks = strengthMax * strengthMax; int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) { for (int strength = 1; strength < strengthMax; ++strength) {
ItemStack start = getStack(type, pH, moisture); ItemStack start = getStack(type, pH, moisture);
ItemStack end = getStack(type + strength, pH, moisture); ItemStack end = getStack(type + strength, pH, moisture);
if (end != null) { if (end != null) {
end.stackSize = numOfBlocks; end.stackSize = numOfBlocks;
Object[] stacks = new Object[numOfBlocks + 1]; Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) { for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start; stacks[i] = start;
} }
stacks[numOfBlocks] = stack.copy(); stacks[numOfBlocks] = stack.copy();
GameRegistry.addShapelessRecipe(end, stacks); GameRegistry.addShapelessRecipe(end, stacks);
} }
numOfBlocks /= 2; numOfBlocks /= 2;
} }
} }
} }
} }
} }
} }
@@ -3,43 +3,43 @@ package binnie.botany.genetics;
import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleInteger;
public class AlleleColor implements IAlleleInteger { public class AlleleColor implements IAlleleInteger {
private String uid; private String uid;
private int value; private int value;
private EnumFlowerColor color; private EnumFlowerColor color;
private boolean dominant = true; private boolean dominant = true;
public AlleleColor(EnumFlowerColor color, String uid, int value) { public AlleleColor(EnumFlowerColor color, String uid, int value) {
this.color = color; this.color = color;
this.uid = uid; this.uid = uid;
this.value = value; this.value = value;
} }
@Override @Override
public String getUID() { public String getUID() {
return uid; return uid;
} }
@Override @Override
public boolean isDominant() { public boolean isDominant() {
return dominant; return dominant;
} }
@Override @Override
public String getName() { public String getName() {
return color.getName(); return color.getName();
} }
@Override @Override
public int getValue() { public int getValue() {
return value; return value;
} }
public EnumFlowerColor getColor() { public EnumFlowerColor getColor() {
return color; return color;
} }
@Override @Override
public String getUnlocalizedName() { public String getUnlocalizedName() {
return getUID(); return getUID();
} }
} }
@@ -7,38 +7,38 @@ import forestry.api.genetics.IEffectData;
import net.minecraft.world.World; import net.minecraft.world.World;
public class AlleleEffectNone implements IAlleleFlowerEffect { public class AlleleEffectNone implements IAlleleFlowerEffect {
@Override @Override
public boolean isCombinable() { public boolean isCombinable() {
return true; return true;
} }
@Override @Override
public IEffectData validateStorage(IEffectData storedData) { public IEffectData validateStorage(IEffectData storedData) {
return storedData; return storedData;
} }
@Override @Override
public String getUID() { public String getUID() {
return "binnie.flowerEffectNone"; return "binnie.flowerEffectNone";
} }
@Override @Override
public boolean isDominant() { public boolean isDominant() {
return false; return false;
} }
@Override @Override
public String getName() { public String getName() {
return I18N.localise("forestry.allele.effect.none"); return I18N.localise("forestry.allele.effect.none");
} }
@Override @Override
public IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z) { public IEffectData doEffect(IFlowerGenome genome, IEffectData storedData, World world, int x, int y, int z) {
return storedData; return storedData;
} }
@Override @Override
public String getUnlocalizedName() { public String getUnlocalizedName() {
return getUID(); return getUID();
} }
} }
@@ -8,23 +8,22 @@ import forestry.core.genetics.BreedingTracker;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
public class BotanistTracker extends BreedingTracker implements IBotanistTracker { public class BotanistTracker extends BreedingTracker implements IBotanistTracker {
public BotanistTracker(String s) { public BotanistTracker(String s) {
super(s); super(s);
} }
@Override @Override
public void registerPickup(IIndividual individual) { public void registerPickup(IIndividual individual) {
// ignored // ignored
} }
@Override @Override
protected IBreedingTracker getBreedingTracker(EntityPlayer player) { protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return Binnie.Genetics.getFlowerRoot() return Binnie.Genetics.getFlowerRoot().getBreedingTracker(player.worldObj, player.getGameProfile());
.getBreedingTracker(player.worldObj, player.getGameProfile()); }
}
@Override @Override
protected String speciesRootUID() { protected String speciesRootUID() {
return "rootFlowers"; return "rootFlowers";
} }
} }
@@ -4,41 +4,40 @@ import binnie.botany.api.IColourMix;
import binnie.botany.api.IFlowerColor; import binnie.botany.api.IFlowerColor;
public class ColorMix implements IColourMix { public class ColorMix implements IColourMix {
protected IFlowerColor color1; protected IFlowerColor color1;
protected IFlowerColor color2; protected IFlowerColor color2;
protected IFlowerColor result; protected IFlowerColor result;
protected int chance; protected int chance;
public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) { public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) {
this.color1 = color1; this.color1 = color1;
this.color2 = color2; this.color2 = color2;
this.result = result; this.result = result;
this.chance = chance; this.chance = chance;
} }
@Override @Override
public IFlowerColor getColor1() { public IFlowerColor getColor1() {
return color1; return color1;
} }
@Override @Override
public IFlowerColor getColor2() { public IFlowerColor getColor2() {
return color2; return color2;
} }
@Override @Override
public boolean isMutation(IFlowerColor color1, IFlowerColor color2) { public boolean isMutation(IFlowerColor color1, IFlowerColor color2) {
return (color1 == this.color1 && color2 == this.color2) return (color1 == this.color1 && color2 == this.color2) || (color1 == this.color2 && color2 == this.color1);
|| (color1 == this.color2 && color2 == this.color1); }
}
@Override @Override
public int getChance() { public int getChance() {
return chance; return chance;
} }
@Override @Override
public IFlowerColor getResult() { public IFlowerColor getResult() {
return result; return result;
} }
} }
File diff suppressed because it is too large. Load diff
@@ -7,146 +7,146 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
public enum EnumFlowerType implements IFlowerType { public enum EnumFlowerType implements IFlowerType {
DANDELION, DANDELION,
POPPY, POPPY,
ORCHID, ORCHID,
ALLIUM, ALLIUM,
BLUET, BLUET,
TULIP, TULIP,
DAISY, DAISY,
CORNFLOWER, CORNFLOWER,
PANSY, PANSY,
IRIS, IRIS,
LAVENDER(2), LAVENDER(2),
VIOLA, VIOLA,
DAFFODIL, DAFFODIL,
DAHLIA, DAHLIA,
PEONY(2), PEONY(2),
ROSE(2), ROSE(2),
LILAC(2), LILAC(2),
HYDRANGEA(2), HYDRANGEA(2),
FOXGLOVE(2), FOXGLOVE(2),
ZINNIA, ZINNIA,
MUMS, MUMS,
MARIGOLD, MARIGOLD,
GERANIUM, GERANIUM,
AZALEA, AZALEA,
PRIMROSE, PRIMROSE,
ASTER, ASTER,
CARNATION, CARNATION,
LILY, LILY,
YARROW, YARROW,
PETUNIA, PETUNIA,
AGAPANTHUS, AGAPANTHUS,
FUCHSIA, FUCHSIA,
DIANTHUS, DIANTHUS,
FORGET, FORGET,
ANEMONE, ANEMONE,
AQUILEGIA, AQUILEGIA,
EDELWEISS, EDELWEISS,
SCABIOUS, SCABIOUS,
CONEFLOWER, CONEFLOWER,
GAILLARDIA, GAILLARDIA,
AURICULA, AURICULA,
CAMELLIA(2), CAMELLIA(2),
GOLDENROD(2), GOLDENROD(2),
ALTHEA(2), ALTHEA(2),
PENSTEMON(2), PENSTEMON(2),
DELPHINIUM(2), DELPHINIUM(2),
HOLLYHOCK(2); HOLLYHOCK(2);
protected int sections; protected int sections;
protected IIcon[] stem; protected IIcon[] stem;
protected IIcon[] petal; protected IIcon[] petal;
protected IIcon[] variant; protected IIcon[] variant;
protected IIcon[] unflowered; protected IIcon[] unflowered;
protected IIcon seedStem; protected IIcon seedStem;
protected IIcon seedPetal; protected IIcon seedPetal;
protected IIcon seedVariant; protected IIcon seedVariant;
protected IIcon pollenStem; protected IIcon pollenStem;
protected IIcon pollenPetal; protected IIcon pollenPetal;
protected IIcon pollenVariant; protected IIcon pollenVariant;
protected IIcon blank; protected IIcon blank;
EnumFlowerType() { EnumFlowerType() {
this(1); this(1);
} }
EnumFlowerType(int sections) { EnumFlowerType(int sections) {
this.sections = sections; this.sections = sections;
stem = new IIcon[sections]; stem = new IIcon[sections];
petal = new IIcon[sections]; petal = new IIcon[sections];
variant = new IIcon[sections]; variant = new IIcon[sections];
unflowered = new IIcon[sections]; unflowered = new IIcon[sections];
} }
@Override @Override
public IIcon getStem(EnumFlowerStage stage, boolean flowered, int section) { public IIcon getStem(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) { if (stage == EnumFlowerStage.SEED) {
return seedStem; return seedStem;
} }
if (stage == EnumFlowerStage.POLLEN) { if (stage == EnumFlowerStage.POLLEN) {
return pollenStem; return pollenStem;
} }
return stem[section % sections]; return stem[section % sections];
} }
@Override @Override
public IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section) { public IIcon getPetalIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) { if (stage == EnumFlowerStage.SEED) {
return seedPetal; return seedPetal;
} }
if (stage == EnumFlowerStage.POLLEN){ if (stage == EnumFlowerStage.POLLEN) {
return pollenPetal; return pollenPetal;
} }
if (flowered) { if (flowered) {
return petal[section % sections]; return petal[section % sections];
} }
return unflowered[section % sections]; return unflowered[section % sections];
} }
@Override @Override
public IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section) { public IIcon getVariantIcon(EnumFlowerStage stage, boolean flowered, int section) {
if (stage == EnumFlowerStage.SEED) { if (stage == EnumFlowerStage.SEED) {
return seedVariant; return seedVariant;
} }
if (stage == EnumFlowerStage.POLLEN) { if (stage == EnumFlowerStage.POLLEN) {
return pollenVariant; return pollenVariant;
} }
return flowered ? variant[section % sections] : blank; return flowered ? variant[section % sections] : blank;
} }
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
for (int i = 0; i < sections; ++i) { for (int i = 0; i < sections; ++i) {
String suf = (i == 0) ? "" : ("" + (i + 1)); String suf = (i == 0) ? "" : ("" + (i + 1));
String pre = (sections == 1) ? "" : "double/"; String pre = (sections == 1) ? "" : "double/";
String id = pre + toString().toLowerCase() + suf; String id = pre + toString().toLowerCase() + suf;
stem[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".0"); stem[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".0");
petal[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".1"); petal[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".1");
variant[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".2"); variant[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".2");
unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".3"); unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + id + ".3");
} }
blank = Botany.proxy.getIcon(register, "flowers/blank"); blank = Botany.proxy.getIcon(register, "flowers/blank");
seedStem = Botany.proxy.getIcon(register, "flowers/seed.0"); seedStem = Botany.proxy.getIcon(register, "flowers/seed.0");
seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1"); seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1");
seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2"); seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2");
pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0"); pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0");
pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1"); pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1");
pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2"); pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2");
} }
@Override @Override
public int getID() { public int getID() {
return ordinal(); return ordinal();
} }
@Override @Override
public int getSections() { public int getSections() {
return sections; return sections;
} }
public IIcon getBlank() { public IIcon getBlank() {
return blank; return blank;
} }
} }
+222 -206
View File
@@ -15,249 +15,265 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome; import forestry.api.genetics.IChromosome;
import forestry.core.genetics.Chromosome; import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Individual; import forestry.core.genetics.Individual;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List;
public class Flower extends Individual implements IFlower { public class Flower extends Individual implements IFlower {
public IFlowerGenome genome; public IFlowerGenome genome;
public IFlowerGenome mate; public IFlowerGenome mate;
protected int age; protected int age;
protected boolean wilting; protected boolean wilting;
protected boolean flowered; protected boolean flowered;
public Flower(NBTTagCompound nbttagcompound) { public Flower(NBTTagCompound nbttagcompound) {
age = 0; age = 0;
wilting = false; wilting = false;
readFromNBT(nbttagcompound); readFromNBT(nbttagcompound);
} }
public Flower(IFlowerGenome genome, int age) { public Flower(IFlowerGenome genome, int age) {
this.genome = genome; this.genome = genome;
this.age = age; this.age = age;
wilting = false; wilting = false;
flowered = age > 0; flowered = age > 0;
} }
@Override @Override
public String getDisplayName() { public String getDisplayName() {
IAlleleFlowerSpecies species = getGenome().getPrimary(); IAlleleFlowerSpecies species = getGenome().getPrimary();
String name = ""; String name = "";
if (species != null) { if (species != null) {
name += species.getName(); name += species.getName();
} }
return name; return name;
} }
@Override @Override
public void addTooltip(List<String> list) { public void addTooltip(List<String> list) {
IAlleleFlowerSpecies primary = genome.getPrimary(); IAlleleFlowerSpecies primary = genome.getPrimary();
IAlleleFlowerSpecies secondary = genome.getSecondary(); IAlleleFlowerSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumFlowerChromosome.SPECIES)) { if (!isPureBred(EnumFlowerChromosome.SPECIES)) {
list.add(EnumChatFormatting.BLUE + I18N.localise("botany.item.tooltip.hybrid", primary.getName(), secondary.getName())); list.add(EnumChatFormatting.BLUE
} + I18N.localise("botany.item.tooltip.hybrid", primary.getName(), secondary.getName()));
}
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.age", getAge())); list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.age", getAge()));
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.temperature", AlleleHelper.toDisplay(primary.getTemperature()), AlleleHelper.toDisplay(genome.getToleranceTemperature()))); list.add(EnumChatFormatting.GREEN
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.moisture", AlleleHelper.toDisplay(primary.getMoisture()), AlleleHelper.toDisplay(genome.getToleranceMoisture()))); + I18N.localise(
list.add(EnumChatFormatting.GREEN + I18N.localise("botany.item.tooltip.pH", AlleleHelper.toDisplay(primary.getHumidity()), AlleleHelper.toDisplay(genome.getTolerancePH()))); "botany.item.tooltip.temperature",
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.fertility", genome.getFertility())); AlleleHelper.toDisplay(primary.getTemperature()),
} AlleleHelper.toDisplay(genome.getToleranceTemperature())));
list.add(EnumChatFormatting.GREEN
+ I18N.localise(
"botany.item.tooltip.moisture",
AlleleHelper.toDisplay(primary.getMoisture()),
AlleleHelper.toDisplay(genome.getToleranceMoisture())));
list.add(EnumChatFormatting.GREEN
+ I18N.localise(
"botany.item.tooltip.pH",
AlleleHelper.toDisplay(primary.getHumidity()),
AlleleHelper.toDisplay(genome.getTolerancePH())));
list.add(EnumChatFormatting.GRAY + I18N.localise("botany.item.tooltip.fertility", genome.getFertility()));
}
@Override @Override
public String getIdent() { public String getIdent() {
return getGenome().getPrimary().getUID(); return getGenome().getPrimary().getUID();
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
if (nbttagcompound == null) { if (nbttagcompound == null) {
genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate()); genome = BotanyCore.getFlowerRoot()
return; .templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
} return;
}
age = nbttagcompound.getInteger("Age"); age = nbttagcompound.getInteger("Age");
wilting = nbttagcompound.getBoolean("Wilt"); wilting = nbttagcompound.getBoolean("Wilt");
flowered = nbttagcompound.getBoolean("Flowered"); flowered = nbttagcompound.getBoolean("Flowered");
if (nbttagcompound.hasKey("Genome")) { if (nbttagcompound.hasKey("Genome")) {
genome = new FlowerGenome(nbttagcompound.getCompoundTag("Genome")); genome = new FlowerGenome(nbttagcompound.getCompoundTag("Genome"));
} }
if (nbttagcompound.hasKey("Mate")) { if (nbttagcompound.hasKey("Mate")) {
mate = new FlowerGenome(nbttagcompound.getCompoundTag("Mate")); mate = new FlowerGenome(nbttagcompound.getCompoundTag("Mate"));
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound); super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("Age", age); nbttagcompound.setInteger("Age", age);
nbttagcompound.setBoolean("Wilt", wilting); nbttagcompound.setBoolean("Wilt", wilting);
nbttagcompound.setBoolean("Flowered", flowered); nbttagcompound.setBoolean("Flowered", flowered);
if (genome != null) { if (genome != null) {
NBTTagCompound NBTmachine = new NBTTagCompound(); NBTTagCompound NBTmachine = new NBTTagCompound();
genome.writeToNBT(NBTmachine); genome.writeToNBT(NBTmachine);
nbttagcompound.setTag("Genome", NBTmachine); nbttagcompound.setTag("Genome", NBTmachine);
} }
if (mate != null) { if (mate != null) {
NBTTagCompound NBTmachine = new NBTTagCompound(); NBTTagCompound NBTmachine = new NBTTagCompound();
mate.writeToNBT(NBTmachine); mate.writeToNBT(NBTmachine);
nbttagcompound.setTag("Mate", NBTmachine); nbttagcompound.setTag("Mate", NBTmachine);
} }
} }
public int getMetadata() { public int getMetadata() {
return 0; return 0;
} }
@Override @Override
public IFlowerGenome getGenome() { public IFlowerGenome getGenome() {
return genome; return genome;
} }
@Override @Override
public void mate(IFlower other) { public void mate(IFlower other) {
mate = new FlowerGenome(other.getGenome().getChromosomes()); mate = new FlowerGenome(other.getGenome().getChromosomes());
} }
@Override @Override
public IFlowerGenome getMate() { public IFlowerGenome getMate() {
return mate; return mate;
} }
@Override @Override
public IFlower copy() { public IFlower copy() {
NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound); writeToNBT(nbttagcompound);
return new Flower(nbttagcompound); return new Flower(nbttagcompound);
} }
@Override @Override
public int getAge() { public int getAge() {
return age; return age;
} }
@Override @Override
public void setAge(int age) { public void setAge(int age) {
this.age = age; this.age = age;
} }
@Override @Override
public void age() { public void age() {
if (age < 15) { if (age < 15) {
age++; age++;
} }
} }
@Override @Override
public int getMaxAge() { public int getMaxAge() {
return getGenome().getLifespan(); return getGenome().getLifespan();
} }
@Override @Override
public boolean isWilted() { public boolean isWilted() {
return wilting; return wilting;
} }
@Override @Override
public void setWilted(boolean value) { public void setWilted(boolean value) {
wilting = value; wilting = value;
} }
@Override @Override
public boolean hasFlowered() { public boolean hasFlowered() {
return flowered; return flowered;
} }
@Override @Override
public void setFlowered(boolean value) { public void setFlowered(boolean value) {
flowered = value; flowered = value;
} }
@Override @Override
public void removeMate() { public void removeMate() {
mate = null; mate = null;
} }
@Override @Override
public IFlower getOffspring(World world) { public IFlower getOffspring(World world) {
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length]; IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
IChromosome[] parent1 = mutateSpecies(world, genome, mate); IChromosome[] parent1 = mutateSpecies(world, genome, mate);
IChromosome[] parent2 = mutateSpecies(world, mate, genome); IChromosome[] parent2 = mutateSpecies(world, mate, genome);
for (int i = 0; i < parent1.length; ++i) { for (int i = 0; i < parent1.length; ++i) {
if (parent1[i] != null && parent2[i] != null) { if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
} }
} }
return new Flower(new FlowerGenome(chromosomes), 0); return new Flower(new FlowerGenome(chromosomes), 0);
} }
private IChromosome[] mutateSpecies(World world, IFlowerGenome genomeOne, IFlowerGenome genomeTwo) { private IChromosome[] mutateSpecies(World world, IFlowerGenome genomeOne, IFlowerGenome genomeTwo) {
IChromosome[] parent1 = genomeOne.getChromosomes(); IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes(); IChromosome[] parent2 = genomeTwo.getChromosomes();
IAllele allele0; IAllele allele0;
IAllele allele2; IAllele allele2;
IFlowerGenome genome0; IFlowerGenome genome0;
IFlowerGenome genome2; IFlowerGenome genome2;
if (world.rand.nextBoolean()) { if (world.rand.nextBoolean()) {
allele0 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele(); allele0 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele(); allele2 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeOne; genome0 = genomeOne;
genome2 = genomeTwo; genome2 = genomeTwo;
} else { } else {
allele0 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele(); allele0 = parent2[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele2 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele(); allele2 = parent1[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeTwo; genome0 = genomeTwo;
genome2 = genomeOne; genome2 = genomeOne;
} }
IFlowerColor colour1 = genome0.getPrimaryColor(); IFlowerColor colour1 = genome0.getPrimaryColor();
IFlowerColor colour2 = genome2.getPrimaryColor(); IFlowerColor colour2 = genome2.getPrimaryColor();
if (colour1 != colour2) { if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) { for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele()); parent1[EnumFlowerChromosome.PRIMARY.ordinal()] =
} new Chromosome(mutation.getResult().getAllele());
} }
} }
}
colour1 = genome0.getSecondaryColor(); colour1 = genome0.getSecondaryColor();
colour2 = genome2.getSecondaryColor(); colour2 = genome2.getSecondaryColor();
if (colour1 != colour2) { if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) { for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele()); parent1[EnumFlowerChromosome.SECONDARY.ordinal()] =
} new Chromosome(mutation.getResult().getAllele());
} }
} }
}
colour1 = genome0.getStemColor(); colour1 = genome0.getStemColor();
colour2 = genome2.getStemColor(); colour2 = genome2.getStemColor();
if (colour1 != colour2) { if (colour1 != colour2) {
for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) { for (IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
parent1[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele()); parent1[EnumFlowerChromosome.STEM.ordinal()] =
} new Chromosome(mutation.getResult().getAllele());
} }
} }
}
IChromosome[] template = null; IChromosome[] template = null;
for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) { for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
float chance = mutation2.getChance(allele0, allele2, genome0, genome2); float chance = mutation2.getChance(allele0, allele2, genome0, genome2);
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) { if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate()); template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
} }
} }
if (template != null) { if (template != null) {
parent1 = template; parent1 = template;
} }
return parent1; return parent1;
} }
} }
@@ -19,112 +19,110 @@ import forestry.core.genetics.Genome;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public class FlowerGenome extends Genome implements IFlowerGenome { public class FlowerGenome extends Genome implements IFlowerGenome {
public FlowerGenome(NBTTagCompound nbttagcompound) { public FlowerGenome(NBTTagCompound nbttagcompound) {
super(nbttagcompound); super(nbttagcompound);
} }
public FlowerGenome(IChromosome[] chromosomes) { public FlowerGenome(IChromosome[] chromosomes) {
super(chromosomes); super(chromosomes);
} }
@Override @Override
public IAlleleFlowerSpecies getPrimary() { public IAlleleFlowerSpecies getPrimary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele(); return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele();
} }
@Override @Override
public IAlleleFlowerSpecies getSecondary() { public IAlleleFlowerSpecies getSecondary() {
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele(); return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele();
} }
@Override @Override
public ISpeciesRoot getSpeciesRoot() { public ISpeciesRoot getSpeciesRoot() {
return BotanyCore.getFlowerRoot(); return BotanyCore.getFlowerRoot();
} }
@Override @Override
public EnumFlowerColor getPrimaryColor() { public EnumFlowerColor getPrimaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.PRIMARY)).getColor(); return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.PRIMARY)).getColor();
} }
@Override @Override
public EnumFlowerColor getSecondaryColor() { public EnumFlowerColor getSecondaryColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.SECONDARY)).getColor(); return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.SECONDARY)).getColor();
} }
@Override @Override
public EnumFlowerColor getStemColor() { public EnumFlowerColor getStemColor() {
return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.STEM)).getColor(); return ((AlleleColor) getActiveAllele(EnumFlowerChromosome.STEM)).getColor();
} }
@Override @Override
public int getFertility() { public int getFertility() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue(); return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue();
} }
@Override @Override
public int getLifespan() { public int getLifespan() {
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5; return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5;
} }
@Override @Override
public IFlowerType getType() { public IFlowerType getType() {
return getPrimary().getType(); return getPrimary().getType();
} }
@Override @Override
public EnumTolerance getToleranceTemperature() { public EnumTolerance getToleranceTemperature() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue(); return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
} }
@Override @Override
public EnumTolerance getToleranceMoisture() { public EnumTolerance getToleranceMoisture() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue(); return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue();
} }
@Override @Override
public EnumTolerance getTolerancePH() { public EnumTolerance getTolerancePH() {
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue(); return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue();
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound); super.readFromNBT(nbttagcompound);
} }
@Override @Override
public float getAgeChance() { public float getAgeChance() {
return 1.0f * (float) Math.sqrt(2.0f / getLifespan()); return 1.0f * (float) Math.sqrt(2.0f / getLifespan());
} }
@Override @Override
public float getSappiness() { public float getSappiness() {
return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue(); return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue();
} }
@Override @Override
public boolean canTolerate(EnumAcidity ePH) { public boolean canTolerate(EnumAcidity ePH) {
int pH = ePH.ordinal(); int pH = ePH.ordinal();
int[] pHTol = Binnie.Genetics.getTolerance(getTolerancePH()); int[] pHTol = Binnie.Genetics.getTolerance(getTolerancePH());
int fPH = getPrimary().getPH().ordinal(); int fPH = getPrimary().getPH().ordinal();
return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1]; return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1];
} }
@Override @Override
public boolean canTolerate(EnumMoisture eMoisture) { public boolean canTolerate(EnumMoisture eMoisture) {
int moisture = eMoisture.ordinal(); int moisture = eMoisture.ordinal();
int[] moistTol = Binnie.Genetics.getTolerance(getToleranceMoisture()); int[] moistTol = Binnie.Genetics.getTolerance(getToleranceMoisture());
int fMoisture = getPrimary().getMoisture().ordinal(); int fMoisture = getPrimary().getMoisture().ordinal();
return moisture >= fMoisture + moistTol[0] return moisture >= fMoisture + moistTol[0] && moisture <= fMoisture + moistTol[1];
&& moisture <= fMoisture + moistTol[1]; }
}
@Override @Override
public boolean canTolerate(EnumTemperature eTemp) { public boolean canTolerate(EnumTemperature eTemp) {
int temp = eTemp.ordinal(); int temp = eTemp.ordinal();
int[] tempTol = Binnie.Genetics.getTolerance(getToleranceTemperature()); int[] tempTol = Binnie.Genetics.getTolerance(getToleranceTemperature());
int fTemp = getPrimary().getTemperature().ordinal(); int fTemp = getPrimary().getTemperature().ordinal();
return temp >= fTemp + tempTol[0] return temp >= fTemp + tempTol[0] && temp <= fTemp + tempTol[1];
&& temp <= fTemp + tempTol[1]; }
}
} }
@@ -18,257 +18,261 @@ import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation; import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesType; import forestry.api.genetics.ISpeciesType;
import forestry.core.genetics.SpeciesRoot; import forestry.core.genetics.SpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class FlowerHelper extends SpeciesRoot implements IFlowerRoot { public class FlowerHelper extends SpeciesRoot implements IFlowerRoot {
public static int flowerSpeciesCount = -1; public static int flowerSpeciesCount = -1;
public static ArrayList<IFlower> flowerTemplates = new ArrayList<>(); public static ArrayList<IFlower> flowerTemplates = new ArrayList<>();
protected static String UID = "rootFlowers"; protected static String UID = "rootFlowers";
private static ArrayList<IFlowerMutation> flowerMutations = new ArrayList<>(); private static ArrayList<IFlowerMutation> flowerMutations = new ArrayList<>();
private static ArrayList<IColourMix> colourMixes = new ArrayList<>(); private static ArrayList<IColourMix> colourMixes = new ArrayList<>();
protected Map<ItemStack, IFlower> conversions; protected Map<ItemStack, IFlower> conversions;
public FlowerHelper() { public FlowerHelper() {
conversions = new HashMap<>(); conversions = new HashMap<>();
} }
@Override @Override
public String getUID() { public String getUID() {
return UID; return UID;
} }
@Override @Override
public int getSpeciesCount() { public int getSpeciesCount() {
if (FlowerHelper.flowerSpeciesCount < 0) { if (FlowerHelper.flowerSpeciesCount < 0) {
FlowerHelper.flowerSpeciesCount = 0; FlowerHelper.flowerSpeciesCount = 0;
for (Map.Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { for (Map.Entry<String, IAllele> entry :
if (entry.getValue() instanceof IAlleleFlowerSpecies && ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) { AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
FlowerHelper.flowerSpeciesCount++; if (entry.getValue() instanceof IAlleleFlowerSpecies
} && ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) {
} FlowerHelper.flowerSpeciesCount++;
} }
return FlowerHelper.flowerSpeciesCount; }
} }
return FlowerHelper.flowerSpeciesCount;
}
@Override @Override
public boolean isMember(ItemStack stack) { public boolean isMember(ItemStack stack) {
return stack != null return stack != null && getStageType(stack) != EnumFlowerStage.NONE;
&& getStageType(stack) != EnumFlowerStage.NONE; }
}
@Override @Override
public boolean isMember(ItemStack stack, int type) { public boolean isMember(ItemStack stack, int type) {
return getStageType(stack).ordinal() == type; return getStageType(stack).ordinal() == type;
} }
@Override @Override
public boolean isMember(IIndividual individual) { public boolean isMember(IIndividual individual) {
return individual instanceof IFlower; return individual instanceof IFlower;
} }
@Override @Override
public ItemStack getMemberStack(IIndividual flower, int type) { public ItemStack getMemberStack(IIndividual flower, int type) {
if (!isMember(flower)) { if (!isMember(flower)) {
return null; return null;
} }
Item flowerItem = Botany.flowerItem; Item flowerItem = Botany.flowerItem;
if (type == EnumFlowerStage.SEED.ordinal()) { if (type == EnumFlowerStage.SEED.ordinal()) {
flowerItem = Botany.seed; flowerItem = Botany.seed;
} }
if (type == EnumFlowerStage.POLLEN.ordinal()) { if (type == EnumFlowerStage.POLLEN.ordinal()) {
flowerItem = Botany.pollen; flowerItem = Botany.pollen;
} }
if (flowerItem != Botany.flowerItem) { if (flowerItem != Botany.flowerItem) {
((IFlower) flower).setAge(0); ((IFlower) flower).setAge(0);
} }
NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound = new NBTTagCompound();
flower.writeToNBT(nbttagcompound); flower.writeToNBT(nbttagcompound);
ItemStack flowerStack = new ItemStack(flowerItem); ItemStack flowerStack = new ItemStack(flowerItem);
flowerStack.setTagCompound(nbttagcompound); flowerStack.setTagCompound(nbttagcompound);
return flowerStack; return flowerStack;
} }
@Override @Override
public EnumFlowerStage getStageType(ItemStack stack) { public EnumFlowerStage getStageType(ItemStack stack) {
if (stack == null) { if (stack == null) {
return EnumFlowerStage.NONE; return EnumFlowerStage.NONE;
} }
if (stack.getItem() == Botany.flowerItem) { if (stack.getItem() == Botany.flowerItem) {
return EnumFlowerStage.FLOWER; return EnumFlowerStage.FLOWER;
} }
if (stack.getItem() == Botany.pollen) { if (stack.getItem() == Botany.pollen) {
return EnumFlowerStage.POLLEN; return EnumFlowerStage.POLLEN;
} }
if (stack.getItem() == Botany.seed) { if (stack.getItem() == Botany.seed) {
return EnumFlowerStage.SEED; return EnumFlowerStage.SEED;
} }
return EnumFlowerStage.NONE; return EnumFlowerStage.NONE;
} }
@Override @Override
public IFlower getMember(ItemStack stack) { public IFlower getMember(ItemStack stack) {
if (!isMember(stack)) { if (!isMember(stack)) {
return null; return null;
} }
return new Flower(stack.getTagCompound()); return new Flower(stack.getTagCompound());
} }
@Override @Override
public IFlower getFlower(World world, IFlowerGenome genome) { public IFlower getFlower(World world, IFlowerGenome genome) {
return new Flower(genome, 2); return new Flower(genome, 2);
} }
@Override @Override
public IFlowerGenome templateAsGenome(IAllele[] template) { public IFlowerGenome templateAsGenome(IAllele[] template) {
return new FlowerGenome(templateAsChromosomes(template)); return new FlowerGenome(templateAsChromosomes(template));
} }
@Override @Override
public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) { public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) {
return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive)); return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive));
} }
@Override @Override
public IFlower templateAsIndividual(IAllele[] template) { public IFlower templateAsIndividual(IAllele[] template) {
return new Flower(templateAsGenome(template), 2); return new Flower(templateAsGenome(template), 2);
} }
@Override @Override
public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) { public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) {
return new Flower(templateAsGenome(templateActive, templateInactive), 2); return new Flower(templateAsGenome(templateActive, templateInactive), 2);
} }
@Override @Override
public ArrayList<IFlower> getIndividualTemplates() { public ArrayList<IFlower> getIndividualTemplates() {
return FlowerHelper.flowerTemplates; return FlowerHelper.flowerTemplates;
} }
@Override @Override
public void registerTemplate(IAllele[] template) { public void registerTemplate(IAllele[] template) {
registerTemplate(template[0].getUID(), template); registerTemplate(template[0].getUID(), template);
} }
@Override @Override
public void registerTemplate(String identifier, IAllele[] template) { public void registerTemplate(String identifier, IAllele[] template) {
FlowerHelper.flowerTemplates.add(new Flower(templateAsGenome(template), 2)); FlowerHelper.flowerTemplates.add(new Flower(templateAsGenome(template), 2));
if (!speciesTemplates.containsKey(identifier)) { if (!speciesTemplates.containsKey(identifier)) {
speciesTemplates.put(identifier, template); speciesTemplates.put(identifier, template);
} }
} }
@Override @Override
public IAllele[] getTemplate(String identifier) { public IAllele[] getTemplate(String identifier) {
return speciesTemplates.get(identifier); return speciesTemplates.get(identifier);
} }
@Override @Override
public IAllele[] getDefaultTemplate() { public IAllele[] getDefaultTemplate() {
return FlowerTemplates.getDefaultTemplate(); return FlowerTemplates.getDefaultTemplate();
} }
@Override @Override
public IAllele[] getRandomTemplate(Random rand) { public IAllele[] getRandomTemplate(Random rand) {
return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())]; return speciesTemplates.values()
} .toArray(new IAllele[0][])[
rand.nextInt(speciesTemplates.values().size())];
}
@Override @Override
public Collection<IFlowerMutation> getMutations(boolean shuffle) { public Collection<IFlowerMutation> getMutations(boolean shuffle) {
if (shuffle) { if (shuffle) {
Collections.shuffle(FlowerHelper.flowerMutations); Collections.shuffle(FlowerHelper.flowerMutations);
} }
return FlowerHelper.flowerMutations; return FlowerHelper.flowerMutations;
} }
@Override @Override
public void registerMutation(IMutation mutation) { public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()) || if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())
AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()) || || AlleleManager.alleleRegistry.isBlacklisted(
AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) { mutation.getAllele0().getUID())
return; || AlleleManager.alleleRegistry.isBlacklisted(
} mutation.getAllele1().getUID())) {
FlowerHelper.flowerMutations.add((IFlowerMutation) mutation); return;
} }
FlowerHelper.flowerMutations.add((IFlowerMutation) mutation);
}
@Override @Override
public IBotanistTracker getBreedingTracker(World world, GameProfile player) { public IBotanistTracker getBreedingTracker(World world, GameProfile player) {
String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId()); String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
BotanistTracker tracker = (BotanistTracker) world.loadItemData(BotanistTracker.class, filename); BotanistTracker tracker = (BotanistTracker) world.loadItemData(BotanistTracker.class, filename);
if (tracker == null) { if (tracker == null) {
tracker = new BotanistTracker(filename); tracker = new BotanistTracker(filename);
world.setItemData(filename, tracker); world.setItemData(filename, tracker);
} }
return tracker; return tracker;
} }
@Override @Override
public IIndividual getMember(NBTTagCompound compound) { public IIndividual getMember(NBTTagCompound compound) {
return new Flower(compound); return new Flower(compound);
} }
@Override @Override
public Class getMemberClass() { public Class getMemberClass() {
return IFlower.class; return IFlower.class;
} }
@Override @Override
public IChromosomeType[] getKaryotype() { public IChromosomeType[] getKaryotype() {
return EnumFlowerChromosome.values(); return EnumFlowerChromosome.values();
} }
@Override @Override
public IChromosomeType getKaryotypeKey() { public IChromosomeType getKaryotypeKey() {
return EnumFlowerChromosome.SPECIES; return EnumFlowerChromosome.SPECIES;
} }
@Override @Override
public void addConversion(ItemStack stack, IAllele[] template) { public void addConversion(ItemStack stack, IAllele[] template) {
IFlower flower = getFlower(null, templateAsGenome(template)); IFlower flower = getFlower(null, templateAsGenome(template));
conversions.put(stack, flower); conversions.put(stack, flower);
} }
@Override @Override
public IFlower getConversion(ItemStack stack) { public IFlower getConversion(ItemStack stack) {
for (Map.Entry<ItemStack, IFlower> entry : conversions.entrySet()) { for (Map.Entry<ItemStack, IFlower> entry : conversions.entrySet()) {
if (entry.getKey().isItemEqual(stack)) { if (entry.getKey().isItemEqual(stack)) {
return (IFlower) entry.getValue().copy(); return (IFlower) entry.getValue().copy();
} }
} }
return null; return null;
} }
@Override @Override
public void registerColourMix(IColourMix colorMix) { public void registerColourMix(IColourMix colorMix) {
FlowerHelper.colourMixes.add(colorMix); FlowerHelper.colourMixes.add(colorMix);
} }
@Override @Override
public Collection<IColourMix> getColourMixes(boolean shuffle) { public Collection<IColourMix> getColourMixes(boolean shuffle) {
if (shuffle) { if (shuffle) {
Collections.shuffle(FlowerHelper.colourMixes); Collections.shuffle(FlowerHelper.colourMixes);
} }
return FlowerHelper.colourMixes; return FlowerHelper.colourMixes;
} }
// ?? // ??
@Override @Override
public ISpeciesType getType(ItemStack stack) { public ISpeciesType getType(ItemStack stack) {
return null; return null;
} }
} }
@@ -6,80 +6,80 @@ import binnie.botany.core.BotanyCore;
import forestry.api.genetics.IAllele; import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome; import forestry.api.genetics.IGenome;
import forestry.api.genetics.ISpeciesRoot; import forestry.api.genetics.ISpeciesRoot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
public class FlowerMutation implements IFlowerMutation { public class FlowerMutation implements IFlowerMutation {
protected IAlleleFlowerSpecies allele0; protected IAlleleFlowerSpecies allele0;
protected IAlleleFlowerSpecies allele1; protected IAlleleFlowerSpecies allele1;
protected IAllele[] template; protected IAllele[] template;
protected int chance; protected int chance;
FlowerMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] template, int chance) { FlowerMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] template, int chance) {
this.allele0 = allele0; this.allele0 = allele0;
this.allele1 = allele1; this.allele1 = allele1;
this.template = template; this.template = template;
this.chance = chance; this.chance = chance;
} }
@Override @Override
public IAlleleFlowerSpecies getAllele0() { public IAlleleFlowerSpecies getAllele0() {
return allele0; return allele0;
} }
@Override @Override
public IAlleleFlowerSpecies getAllele1() { public IAlleleFlowerSpecies getAllele1() {
return allele1; return allele1;
} }
@Override @Override
public IAllele[] getTemplate() { public IAllele[] getTemplate() {
return template; return template;
} }
@Override @Override
public float getBaseChance() { public float getBaseChance() {
return chance; return chance;
} }
@Override @Override
public boolean isPartner(IAllele allele) { public boolean isPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID()) return allele.getUID().equals(allele0.getUID()) || allele.getUID().equals(allele1.getUID());
|| allele.getUID().equals(allele1.getUID()); }
}
@Override @Override
public IAllele getPartner(IAllele allele) { public IAllele getPartner(IAllele allele) {
return allele.getUID().equals(allele0.getUID()) ? allele1 : allele0; return allele.getUID().equals(allele0.getUID()) ? allele1 : allele0;
} }
@Override @Override
public boolean isSecret() { public boolean isSecret() {
return false; return false;
} }
@Override @Override
public float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { public float getChance(IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
if (allele0 == null || allele1 == null) { if (allele0 == null || allele1 == null) {
return 0.0f; return 0.0f;
} }
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) { if (this.allele0.getUID().equals(allele0.getUID())
return getBaseChance(); && this.allele1.getUID().equals(allele1.getUID())) {
} return getBaseChance();
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) { }
return getBaseChance(); if (this.allele1.getUID().equals(allele0.getUID())
} && this.allele0.getUID().equals(allele1.getUID())) {
return 0.0f; return getBaseChance();
} }
return 0.0f;
}
@Override @Override
public ISpeciesRoot getRoot() { public ISpeciesRoot getRoot() {
return BotanyCore.getFlowerRoot(); return BotanyCore.getFlowerRoot();
} }
@Override @Override
public Collection<String> getSpecialConditions() { public Collection<String> getSpecialConditions() {
return new ArrayList<>(); return new ArrayList<>();
} }
} }
File diff suppressed because it is too large. Load diff
@@ -7,20 +7,20 @@ import forestry.api.genetics.IAllele;
import forestry.core.genetics.alleles.EnumAllele; import forestry.core.genetics.alleles.EnumAllele;
public class FlowerTemplates { public class FlowerTemplates {
public static IAllele[] getDefaultTemplate() { public static IAllele[] getDefaultTemplate() {
IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length]; IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
alleles[EnumFlowerChromosome.SPECIES.ordinal()] = FlowerSpecies.POPPY; alleles[EnumFlowerChromosome.SPECIES.ordinal()] = FlowerSpecies.POPPY;
alleles[EnumFlowerChromosome.PRIMARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED); alleles[EnumFlowerChromosome.PRIMARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.SECONDARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED); alleles[EnumFlowerChromosome.SECONDARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.FERTILITY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Fertility.NORMAL); alleles[EnumFlowerChromosome.FERTILITY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Fertility.NORMAL);
alleles[EnumFlowerChromosome.TERRITORY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Territory.AVERAGE); alleles[EnumFlowerChromosome.TERRITORY.ordinal()] = AlleleHelper.getAllele(EnumAllele.Territory.AVERAGE);
alleles[EnumFlowerChromosome.EFFECT.ordinal()] = ModuleGenetics.alleleEffectNone; alleles[EnumFlowerChromosome.EFFECT.ordinal()] = ModuleGenetics.alleleEffectNone;
alleles[EnumFlowerChromosome.LIFESPAN.ordinal()] = AlleleHelper.getAllele(EnumAllele.Lifespan.NORMAL); alleles[EnumFlowerChromosome.LIFESPAN.ordinal()] = AlleleHelper.getAllele(EnumAllele.Lifespan.NORMAL);
alleles[EnumFlowerChromosome.TEMPERATURE_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE); alleles[EnumFlowerChromosome.TEMPERATURE_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.HUMIDITY_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE); alleles[EnumFlowerChromosome.HUMIDITY_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.PH_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE); alleles[EnumFlowerChromosome.PH_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.SAPPINESS.ordinal()] = AlleleHelper.getAllele(EnumAllele.Sappiness.AVERAGE); alleles[EnumFlowerChromosome.SAPPINESS.ordinal()] = AlleleHelper.getAllele(EnumAllele.Sappiness.AVERAGE);
alleles[EnumFlowerChromosome.STEM.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.GREEN); alleles[EnumFlowerChromosome.STEM.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.GREEN);
return alleles; return alleles;
} }
} }
@@ -6,6 +6,7 @@ import binnie.botany.core.BotanyGUI;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -14,54 +15,52 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List;
public class ItemDictionary extends Item { public class ItemDictionary extends Item {
protected IIcon iconMaster; protected IIcon iconMaster;
public ItemDictionary() { public ItemDictionary() {
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("database"); setUnlocalizedName("database");
setMaxStackSize(1); setMaxStackSize(1);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "botanistDatabase"); itemIcon = Botany.proxy.getIcon(register, "botanistDatabase");
iconMaster = Botany.proxy.getIcon(register, "masterBotanistDatabase"); iconMaster = Botany.proxy.getIcon(register, "masterBotanistDatabase");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) { public IIcon getIconFromDamage(int damage) {
return (damage == 0) ? itemIcon : iconMaster; return (damage == 0) ? itemIcon : iconMaster;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) { public void getSubItems(Item item, CreativeTabs tab, List list) {
super.getSubItems(item, tab, list); super.getSubItems(item, tab, list);
list.add(new ItemStack(item, 1, 1)); list.add(new ItemStack(item, 1, 1));
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BotanyGUI guiId = (stack.getItemDamage() == 0) ? BotanyGUI.Database : BotanyGUI.DatabaseNEI; BotanyGUI guiId = (stack.getItemDamage() == 0) ? BotanyGUI.Database : BotanyGUI.DatabaseNEI;
Botany.proxy.openGui(guiId, player, (int) player.posX, (int) player.posY, (int) player.posZ); Botany.proxy.openGui(guiId, player, (int) player.posX, (int) player.posY, (int) player.posZ);
return stack; return stack;
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return (stack.getItemDamage() == 0) return (stack.getItemDamage() == 0)
? I18N.localise("botany.item.database.0.name") ? I18N.localise("botany.item.database.0.name")
: I18N.localise("botany.item.database.1.name"); : I18N.localise("botany.item.database.1.name");
} }
} }
@@ -22,56 +22,63 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class ModuleGenetics implements IInitializable { public class ModuleGenetics implements IInitializable {
static AlleleEffectNone alleleEffectNone = new AlleleEffectNone(); static AlleleEffectNone alleleEffectNone = new AlleleEffectNone();
@Override @Override
public void preInit() { public void preInit() {
EnumFlowerColor.setupMutations(); EnumFlowerColor.setupMutations();
Botany.flower = new BlockFlower(); Botany.flower = new BlockFlower();
Botany.flowerItem = new ItemFlower(); Botany.flowerItem = new ItemFlower();
Botany.pollen = new ItemPollen(); Botany.pollen = new ItemPollen();
Botany.seed = new ItemSeed(); Botany.seed = new ItemSeed();
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.speciesRoot); AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.speciesRoot);
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone); AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
GameRegistry.registerBlock(Botany.flower, "flower"); GameRegistry.registerBlock(Botany.flower, "flower");
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null); BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
Botany.database = new ItemDictionary(); Botany.database = new ItemDictionary();
} }
@Override @Override
public void init() { public void init() {
for (EnumFlowerColor color : EnumFlowerColor.values()) { for (EnumFlowerColor color : EnumFlowerColor.values()) {
AlleleManager.alleleRegistry.registerAllele(color.getAllele()); AlleleManager.alleleRegistry.registerAllele(color.getAllele());
} }
FlowerSpecies.setupVariants(); FlowerSpecies.setupVariants();
for (FlowerSpecies species : FlowerSpecies.values()) { for (FlowerSpecies species : FlowerSpecies.values()) {
AlleleManager.alleleRegistry.registerAllele(species); AlleleManager.alleleRegistry.registerAllele(species);
BotanyCore.getFlowerRoot().registerTemplate(species.getUID(), species.getTemplate()); BotanyCore.getFlowerRoot().registerTemplate(species.getUID(), species.getTemplate());
for (IAllele[] variant : species.getVariants()) { for (IAllele[] variant : species.getVariants()) {
BotanyCore.getFlowerRoot().registerTemplate(variant); BotanyCore.getFlowerRoot().registerTemplate(variant);
} }
} }
RendererBotany.renderID = RenderingRegistry.getNextAvailableRenderId(); RendererBotany.renderID = RenderingRegistry.getNextAvailableRenderId();
BinnieCore.proxy.registerBlockRenderer(new RendererBotany()); BinnieCore.proxy.registerBlockRenderer(new RendererBotany());
} }
@Override @Override
public void postInit() { public void postInit() {
FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla"); FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
RecipeManagers.carpenterManager.addRecipe( RecipeManagers.carpenterManager.addRecipe(
100, 100,
Binnie.Liquid.getLiquidStack("water", 2000), Binnie.Liquid.getLiquidStack("water", 2000),
null, null,
new ItemStack(Botany.database), new ItemStack(Botany.database),
"X#X", "YEY", "RDR", "X#X",
'#', Blocks.glass_pane, "YEY",
'X', Items.gold_ingot, "RDR",
'Y', Items.gold_nugget, '#',
'R', Items.redstone, Blocks.glass_pane,
'D', Items.diamond, 'X',
'E', Items.emerald Items.gold_ingot,
); 'Y',
} Items.gold_nugget,
'R',
Items.redstone,
'D',
Items.diamond,
'E',
Items.emerald);
}
} }
@@ -3,58 +3,57 @@ package binnie.botany.items;
import binnie.botany.Botany; import binnie.botany.Botany;
import binnie.core.item.IItemMisc; import binnie.core.item.IItemMisc;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import java.util.List;
public enum BotanyItems implements IItemMisc { public enum BotanyItems implements IItemMisc {
AshPowder("powderAsh"), AshPowder("powderAsh"),
PulpPowder("powderPulp"), PulpPowder("powderPulp"),
MulchPowder("powderMulch"), MulchPowder("powderMulch"),
SulphurPowder("powderSulphur"), SulphurPowder("powderSulphur"),
FertiliserPowder("powderFertiliser"), FertiliserPowder("powderFertiliser"),
CompostPowder("powderCompost"), CompostPowder("powderCompost"),
Mortar("mortar"), Mortar("mortar"),
Weedkiller("weedkiller"); Weedkiller("weedkiller");
protected IIcon icon; protected IIcon icon;
protected String name; protected String name;
protected String iconPath; protected String iconPath;
BotanyItems(String name) { BotanyItems(String name) {
this.name = name; this.name = name;
this.iconPath = name; this.iconPath = name;
} }
@Override @Override
public IIcon getIcon(ItemStack itemStack) { public IIcon getIcon(ItemStack itemStack) {
return icon; return icon;
} }
@Override @Override
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
icon = Botany.proxy.getIcon(register, iconPath); icon = Botany.proxy.getIcon(register, iconPath);
} }
@Override @Override
public void addInformation(List data) { public void addInformation(List data) {
// ignored // ignored
} }
@Override @Override
public String getName(ItemStack itemStack) { public String getName(ItemStack itemStack) {
return I18N.localise("botany.item." + name + ".name"); return I18N.localise("botany.item." + name + ".name");
} }
@Override @Override
public ItemStack get(int count) { public ItemStack get(int count) {
return new ItemStack(Botany.misc, count, ordinal()); return new ItemStack(Botany.misc, count, ordinal());
} }
@Override @Override
public boolean isActive() { public boolean isActive() {
return true; return true;
} }
} }
+34 -34
View File
@@ -6,6 +6,7 @@ import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -13,44 +14,43 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import java.util.List;
public class ItemClay extends Item { public class ItemClay extends Item {
public ItemClay() { public ItemClay() {
setUnlocalizedName("clay"); setUnlocalizedName("clay");
setHasSubtypes(true); setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
} }
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName()); tooltip.add(EnumChatFormatting.GRAY
} + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) { public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage(); int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false); return EnumFlowerColor.get(damage).getColor(false);
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.clay.name"); return I18N.localise("botany.item.clay.name");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) { public void getSubItems(Item item, CreativeTabs tab, List list) {
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal())); list.add(new ItemStack(this, 1, c.ordinal()));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "clay"); itemIcon = Botany.proxy.getIcon(register, "clay");
} }
} }
@@ -6,6 +6,7 @@ import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.util.I18N; import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -13,44 +14,43 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import java.util.List;
public class ItemPigment extends Item { public class ItemPigment extends Item {
public ItemPigment() { public ItemPigment() {
setUnlocalizedName("pigment"); setUnlocalizedName("pigment");
setHasSubtypes(true); setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance); setCreativeTab(CreativeTabBotany.instance);
} }
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
tooltip.add(EnumChatFormatting.GRAY + EnumFlowerColor.get(stack.getItemDamage()).getName()); tooltip.add(EnumChatFormatting.GRAY
} + EnumFlowerColor.get(stack.getItemDamage()).getName());
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int index) { public int getColorFromItemStack(ItemStack stack, int index) {
int damage = stack.getItemDamage(); int damage = stack.getItemDamage();
return EnumFlowerColor.get(damage).getColor(false); return EnumFlowerColor.get(damage).getColor(false);
} }
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
return I18N.localise("botany.item.pigment.name"); return I18N.localise("botany.item.pigment.name");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) { public void getSubItems(Item item, CreativeTabs tab, List list) {
for (EnumFlowerColor c : EnumFlowerColor.values()) { for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal())); list.add(new ItemStack(this, 1, c.ordinal()));
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) { public void registerIcons(IIconRegister register) {
itemIcon = Botany.proxy.getIcon(register, "pigment"); itemIcon = Botany.proxy.getIcon(register, "pigment");
} }
} }
@@ -6,45 +6,44 @@ import binnie.botany.genetics.EnumFlowerType;
import binnie.core.network.packet.MessageBinnie; import binnie.core.network.packet.MessageBinnie;
import binnie.core.network.packet.MessageCoordinates; import binnie.core.network.packet.MessageCoordinates;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException; import java.io.IOException;
public class MessageFlowerUpdate extends MessageCoordinates { public class MessageFlowerUpdate extends MessageCoordinates {
public TileEntityFlower.RenderInfo render; public TileEntityFlower.RenderInfo render;
public MessageFlowerUpdate(int posX, int posY, int posZ, TileEntityFlower.RenderInfo render) { public MessageFlowerUpdate(int posX, int posY, int posZ, TileEntityFlower.RenderInfo render) {
super(PacketID.FlowerUpdate.ordinal(), posX, posY, posZ); super(PacketID.FlowerUpdate.ordinal(), posX, posY, posZ);
this.render = render; this.render = render;
} }
public MessageFlowerUpdate(MessageBinnie message) { public MessageFlowerUpdate(MessageBinnie message) {
super(message); super(message);
} }
@Override @Override
public void writeData(ByteBuf data) throws IOException { public void writeData(ByteBuf data) throws IOException {
super.writeData(data); super.writeData(data);
data.writeByte(render.primary.getID()); data.writeByte(render.primary.getID());
data.writeByte(render.secondary.getID()); data.writeByte(render.secondary.getID());
data.writeByte(render.stem.getID()); data.writeByte(render.stem.getID());
data.writeByte(render.type.ordinal()); data.writeByte(render.type.ordinal());
data.writeByte(render.age); data.writeByte(render.age);
data.writeByte(render.section); data.writeByte(render.section);
data.writeBoolean(render.wilted); data.writeBoolean(render.wilted);
data.writeBoolean(render.flowered); data.writeBoolean(render.flowered);
} }
@Override @Override
public void readData(ByteBuf data) throws IOException { public void readData(ByteBuf data) throws IOException {
super.readData(data); super.readData(data);
render = new TileEntityFlower.RenderInfo(); render = new TileEntityFlower.RenderInfo();
render.primary = EnumFlowerColor.values()[data.readByte()]; render.primary = EnumFlowerColor.values()[data.readByte()];
render.secondary = EnumFlowerColor.values()[data.readByte()]; render.secondary = EnumFlowerColor.values()[data.readByte()];
render.stem = EnumFlowerColor.values()[data.readByte()]; render.stem = EnumFlowerColor.values()[data.readByte()];
render.type = EnumFlowerType.values()[data.readByte()]; render.type = EnumFlowerType.values()[data.readByte()];
render.age = data.readByte(); render.age = data.readByte();
render.section = data.readByte(); render.section = data.readByte();
render.wilted = data.readBoolean(); render.wilted = data.readBoolean();
render.flowered = data.readBoolean(); render.flowered = data.readBoolean();
} }
} }
@@ -17,74 +17,76 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
public enum PacketID implements IPacketID { public enum PacketID implements IPacketID {
FieldKit, FieldKit,
FlowerUpdate; FlowerUpdate;
@Override @Override
public void onMessage(MessageBinnie message, MessageContext context) { public void onMessage(MessageBinnie message, MessageContext context) {
if (this == PacketID.FieldKit && context.side == Side.CLIENT) { if (this == PacketID.FieldKit && context.side == Side.CLIENT) {
onFieldKitPacket(message); onFieldKitPacket(message);
} else if (this == PacketID.FlowerUpdate) { } else if (this == PacketID.FlowerUpdate) {
onFlowerUpdatePacket(message); onFlowerUpdatePacket(message);
} }
} }
private void onFlowerUpdatePacket(MessageBinnie message) { private void onFlowerUpdatePacket(MessageBinnie message) {
MessageFlowerUpdate packet = new MessageFlowerUpdate(message); MessageFlowerUpdate packet = new MessageFlowerUpdate(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld()); TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityFlower) { if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).setRender(packet.render); ((TileEntityFlower) tile).setRender(packet.render);
} }
} }
private void onFieldKitPacket(MessageBinnie message) { private void onFieldKitPacket(MessageBinnie message) {
MessageNBT packet = new MessageNBT(message); MessageNBT packet = new MessageNBT(message);
NBTTagCompound data = packet.getTagCompound(); NBTTagCompound data = packet.getTagCompound();
EntityPlayer player = BinnieCore.proxy.getPlayer(); EntityPlayer player = BinnieCore.proxy.getPlayer();
String info = ""; String info = "";
if (data.hasNoTags()) { if (data.hasNoTags()) {
info += "Flower has not been discovered by you. Breed this flower yourself to discover."; info += "Flower has not been discovered by you. Breed this flower yourself to discover.";
} else { } else {
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species")); IAlleleFlowerSpecies primary =
IAlleleFlowerSpecies secondary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species2")); (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species"));
float age = data.getFloat("Age"); IAlleleFlowerSpecies secondary =
EnumFlowerColor color1 = EnumFlowerColor.get(data.getShort("Colour")); (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species2"));
EnumFlowerColor color2 = EnumFlowerColor.get(data.getShort("Colour2")); float age = data.getFloat("Age");
if (primary == null || secondary == null) { EnumFlowerColor color1 = EnumFlowerColor.get(data.getShort("Colour"));
return; EnumFlowerColor color2 = EnumFlowerColor.get(data.getShort("Colour2"));
} if (primary == null || secondary == null) {
return;
}
info += "A"; info += "A";
if (age == 0.0f) { if (age == 0.0f) {
info += ""; info += "";
} else if (age < 0.25f) { } else if (age < 0.25f) {
info += " Young"; info += " Young";
} else if (age < 0.75f) { } else if (age < 0.75f) {
info += " Mature"; info += " Mature";
} else { } else {
info += " Old"; info += " Old";
} }
if (color1 == color2) { if (color1 == color2) {
info = info + " " + color1.getName(); info = info + " " + color1.getName();
} else { } else {
info = info + " " + color1.getName() + " & " + color2.getName(); info = info + " " + color1.getName() + " & " + color2.getName();
} }
if (primary == secondary) { if (primary == secondary) {
info = info + " " + primary.getName(); info = info + " " + primary.getName();
} else { } else {
info = info + " " + primary.getName() + "-" + secondary.getName() + " Hybrid"; info = info + " " + primary.getName() + "-" + secondary.getName() + " Hybrid";
} }
if (age == 0.0f) { if (age == 0.0f) {
info += " Germling"; info += " Germling";
} }
if (data.getBoolean("Wilting")) { if (data.getBoolean("Wilting")) {
info += ". Shame it is Wilting!"; info += ". Shame it is Wilting!";
} }
} }
IChatComponent chat = new ChatComponentText(info); IChatComponent chat = new ChatComponentText(info);
player.addChatMessage(chat); player.addChatMessage(chat);
} }
} }
@@ -2,5 +2,4 @@ package binnie.botany.proxy;
import binnie.core.proxy.IProxyCore; import binnie.core.proxy.IProxyCore;
public interface IBotanyProxy extends IProxyCore { public interface IBotanyProxy extends IProxyCore {}
}
+3 -3
View File
@@ -4,7 +4,7 @@ import binnie.botany.Botany;
import binnie.core.proxy.BinnieModProxy; import binnie.core.proxy.BinnieModProxy;
public class Proxy extends BinnieModProxy implements IBotanyProxy { public class Proxy extends BinnieModProxy implements IBotanyProxy {
public Proxy() { public Proxy() {
super(Botany.instance); super(Botany.instance);
} }
} }
Loaded 100 of 857 files, more files were not shown because too many files have changed in this diff. Show more