diff --git a/.gitignore b/.gitignore index 05de4542..68123f68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -/build/build -/build/.gradle +build/build/* +build/run/* +build/.gradle/* +*.ipr +*.iml +*.iws .idea/** diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..19d1fa01 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +.1996 diff --git a/COPYING.LESSER b/COPYING.LESSER new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser 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 +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/LICENSE.txt b/LICENSE.txt index bed16e88..2bfb5503 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,3 +1,13 @@ +GTNH Modifications: + +GNU LESSER GENERAL PUBLIC LICENSE - See COPYING & COPYING.LESSER + +Copyright (c) 2019 mitchej123 + + + +Base NEI License: + The MIT License (MIT) Copyright (c) 2014 ChickenBones diff --git a/build/build.gradle b/build/build.gradle index c6132db6..86e493e5 100644 --- a/build/build.gradle +++ b/build/build.gradle @@ -45,6 +45,11 @@ dependencies { version = "${project.config.mod_version}" +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + println config.mc_version + "-" + config.forge_version // Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here minecraft { @@ -106,6 +111,10 @@ artifacts { archives sourceJar, devJar } +sourceSets { + main { output.resourcesDir = output.classesDir } +} + // Configure an upload task. uploadArchives { dependsOn 'reobf' diff --git a/build/build.properties b/build/build.properties index f272e0b9..1f4beb2e 100644 --- a/build/build.properties +++ b/build/build.properties @@ -1,5 +1,5 @@ mc_version=1.7.10 -forge_version=10.13.4.1448-1.7.10 +forge_version=10.13.4.1614-1.7.10 ccl_version=1.1.3.138 ccc_version=1.0.7.+ -mod_version=1.0.6-GTNH +mod_version=2.0.0-pre-3-GTNH diff --git a/resources/assets/nei/lang/cs_CZ.lang b/resources/assets/nei/lang/cs_CZ.lang index 298776dc..0582d88b 100644 --- a/resources/assets/nei/lang/cs_CZ.lang +++ b/resources/assets/nei/lang/cs_CZ.lang @@ -84,7 +84,6 @@ nei.options.inventory.widgetsenabled.false=NEI zakázáno nei.options.inventory.cheatmode.0=Mód receptů nei.options.inventory.cheatmode.1=Užitný mód nei.options.inventory.cheatmode.2=Cheatovací mód -nei.options.inventory.layoutstyle=Styl vzhledu nei.options.inventory.profileRecipes=Profilové recepty nei.options.inventory.profileRecipes.true=Povoleny nei.options.inventory.profileRecipes.false=Nepovoleny @@ -153,8 +152,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Staré TMI + + nei.recipe.page=Strana %s/%s nei.recipe.shaped=Výhodná výroba diff --git a/resources/assets/nei/lang/de_DE.lang b/resources/assets/nei/lang/de_DE.lang index 3b67e404..1f9b78b6 100644 --- a/resources/assets/nei/lang/de_DE.lang +++ b/resources/assets/nei/lang/de_DE.lang @@ -88,7 +88,6 @@ nei.options.inventory.widgetsenabled.false=NEI Deaktiviert nei.options.inventory.cheatmode.0=Rezeptmodus nei.options.inventory.cheatmode.1=Mehrzweckmodus nei.options.inventory.cheatmode.2=Cheat-Modus -nei.options.inventory.layoutstyle=Layout-Stil nei.options.inventory.profileRecipes=Profil-Rezepte nei.options.inventory.profileRecipes.true=Wahr nei.options.inventory.profileRecipes.false=Falsch @@ -161,8 +160,8 @@ nei.options.tools.dump.itempanel.mode.3=PNG nei.options.tools.dump.itempanel.icon.dumped=Icons des Item-Panels wurden nach %s exportiert nei.options.tools.dump.itempanel.icon.cancelled=Export abgebrochen -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Altes TMI + + nei.recipe.page=Seite %s/%s nei.recipe.tooltip=Rezepte diff --git a/resources/assets/nei/lang/en_US.lang b/resources/assets/nei/lang/en_US.lang index 428da3a5..e0a0a7d8 100644 --- a/resources/assets/nei/lang/en_US.lang +++ b/resources/assets/nei/lang/en_US.lang @@ -1,5 +1,6 @@ nei.load=Load nei.save=Save +nei.bookmark.toggle=Bookmarks nei.enchant=Enchant nei.enchant.level=Level @@ -69,6 +70,7 @@ nei.options.keys.gui.prev=Prev Page nei.options.keys.gui.next=Next Page nei.options.keys.gui.hide=Toggle NEI Visibility nei.options.keys.gui.search=Focus Search Bar +nei.options.keys.gui.bookmark=Add Bookmark nei.options.keys.world=World nei.options.keys.world.chunkoverlay=Chunk Boundary Overlay nei.options.keys.world.moboverlay=Mob Spawn Overlay @@ -88,7 +90,6 @@ nei.options.inventory.widgetsenabled.false=NEI Disabled nei.options.inventory.cheatmode.0=Recipe Mode nei.options.inventory.cheatmode.1=Utility Mode nei.options.inventory.cheatmode.2=Cheat Mode -nei.options.inventory.layoutstyle=Layout Style nei.options.inventory.profileRecipes=Profile Recipes nei.options.inventory.profileRecipes.true=True nei.options.inventory.profileRecipes.false=False @@ -161,8 +162,8 @@ nei.options.tools.dump.itempanel.mode.3=PNG nei.options.tools.dump.itempanel.icon.dumped=Item Panel icons were dumped to %s nei.options.tools.dump.itempanel.icon.cancelled=Dump cancelled -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Old TMI + + nei.recipe.page=Page %s/%s nei.recipe.tooltip=Recipes diff --git a/resources/assets/nei/lang/et_EE.lang b/resources/assets/nei/lang/et_EE.lang index 446d6743..78fddc64 100644 --- a/resources/assets/nei/lang/et_EE.lang +++ b/resources/assets/nei/lang/et_EE.lang @@ -87,7 +87,6 @@ nei.options.inventory.widgetsenabled.false=NEI keelatud nei.options.inventory.cheatmode.0=Retsepti mood nei.options.inventory.cheatmode.1=Utiliidi mood nei.options.inventory.cheatmode.2=Petmis mood -nei.options.inventory.layoutstyle=Layout Style nei.options.inventory.profileRecipes=Profileeri retsepte nei.options.inventory.profileRecipes.true=Tõene nei.options.inventory.profileRecipes.false=Väär @@ -156,8 +155,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Vana TMI + + nei.recipe.page=Leht %s/%s nei.recipe.shaped=Kujuga Valmistamine diff --git a/resources/assets/nei/lang/fr_FR.lang b/resources/assets/nei/lang/fr_FR.lang index 776effb3..b84c781c 100644 --- a/resources/assets/nei/lang/fr_FR.lang +++ b/resources/assets/nei/lang/fr_FR.lang @@ -85,7 +85,6 @@ nei.options.inventory.widgetsenabled.false=NEI désactivé nei.options.inventory.cheatmode.0=Mode recette nei.options.inventory.cheatmode.1=Mode utilitaire nei.options.inventory.cheatmode.2=Mode triche -nei.options.inventory.layoutstyle=Mise en page nei.options.inventory.profileRecipes=Profil Recettes nei.options.inventory.profileRecipes.true=Vrai nei.options.inventory.profileRecipes.false=Faux @@ -154,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Ancien TMI + + nei.recipe.page=Page %s/%s nei.recipe.shaped=Modèle de recette diff --git a/resources/assets/nei/lang/it_IT.lang b/resources/assets/nei/lang/it_IT.lang index 63302230..85a8576f 100644 --- a/resources/assets/nei/lang/it_IT.lang +++ b/resources/assets/nei/lang/it_IT.lang @@ -88,7 +88,6 @@ nei.options.inventory.widgetsenabled.false=NEI Disattivato nei.options.inventory.cheatmode.0=Modalità ricette nei.options.inventory.cheatmode.1=Modalità utilità nei.options.inventory.cheatmode.2=Modalità cheat -nei.options.inventory.layoutstyle=Stile layout nei.options.inventory.profileRecipes=Ricerca profilo nei.options.inventory.profileRecipes.true=Vero nei.options.inventory.profileRecipes.false=Falso @@ -161,8 +160,8 @@ nei.options.tools.dump.itempanel.mode.3=PNG nei.options.tools.dump.itempanel.icon.dumped=Le icone del Item Panel è stato scricato ino %s nei.options.tools.dump.itempanel.icon.cancelled=File scaricati eliminati -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Vecchio TMI + + nei.recipe.page=Pagina %s/%s nei.recipe.tooltip=Ricette diff --git a/resources/assets/nei/lang/ko_KR.lang b/resources/assets/nei/lang/ko_KR.lang index f1d4d543..d66aba62 100644 --- a/resources/assets/nei/lang/ko_KR.lang +++ b/resources/assets/nei/lang/ko_KR.lang @@ -84,7 +84,6 @@ nei.options.inventory.widgetsenabled.false=NEI 비활성화 nei.options.inventory.cheatmode.0=레시피모드 nei.options.inventory.cheatmode.1=유틸리티모드 nei.options.inventory.cheatmode.2=치트모드 -nei.options.inventory.layoutstyle=레이아웃 스타일 nei.options.inventory.profileRecipes=프로파일 레시피 nei.options.inventory.profileRecipes.true=설정 nei.options.inventory.profileRecipes.false=비설정 @@ -153,9 +152,6 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -layoutstyle.minecraft=마인크래프트 -layoutstyle.oldtmi=투매니 아이템 - nei.recipe.page=%s/%s 페이지 nei.recipe.shaped=무형 조합법 nei.recipe.shapeless=유형 조합법 diff --git a/resources/assets/nei/lang/pl_PL.lang b/resources/assets/nei/lang/pl_PL.lang index fafa832f..93a4162e 100644 --- a/resources/assets/nei/lang/pl_PL.lang +++ b/resources/assets/nei/lang/pl_PL.lang @@ -85,7 +85,7 @@ nei.options.inventory.widgetsenabled.false=NEI wyłączone nei.options.inventory.cheatmode.0=Tryb recept nei.options.inventory.cheatmode.1=Tryb użytku nei.options.inventory.cheatmode.2=Tryb oszukiwania -nei.options.inventory.layoutstyle=Styl układu + nei.options.inventory.profileRecipes=Profiluj recepty nei.options.inventory.profileRecipes.true=Tak nei.options.inventory.profileRecipes.false=Nie @@ -158,8 +158,8 @@ nei.options.tools.dump.itempanel.mode.3=PNG nei.options.tools.dump.itempanel.icon.dumped=Ikony panelu przedmiotów zrzucone do %s nei.options.tools.dump.itempanel.icon.cancelled=Zrzut anulowany -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Stare TMI + + nei.recipe.page=Strona %s/%s nei.recipe.shaped=Kształtne wytwarzanie diff --git a/resources/assets/nei/lang/pt_BR.lang b/resources/assets/nei/lang/pt_BR.lang index f694bb4e..eb6cb859 100644 --- a/resources/assets/nei/lang/pt_BR.lang +++ b/resources/assets/nei/lang/pt_BR.lang @@ -84,7 +84,7 @@ nei.options.inventory.widgetsenabled.false=NEI Desativado nei.options.inventory.cheatmode.0=Modo Receitas nei.options.inventory.cheatmode.1=Modo Utilidade nei.options.inventory.cheatmode.2=Modo Cheat -nei.options.inventory.layoutstyle=Estilo de Layout + nei.options.inventory.profileRecAtivaripes=Perfilar Receitas nei.options.inventory.profileRecipes.true=Verdadeiro nei.options.inventory.profileRecipes.false=Falso @@ -153,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Velho TMI + + nei.recipe.page=Página %s/%s nei.recipe.shaped=Receita Exata diff --git a/resources/assets/nei/lang/ru_RU.lang b/resources/assets/nei/lang/ru_RU.lang index f879154d..4918e0c3 100644 --- a/resources/assets/nei/lang/ru_RU.lang +++ b/resources/assets/nei/lang/ru_RU.lang @@ -88,7 +88,7 @@ nei.options.inventory.widgetsenabled.false=NEI выключен nei.options.inventory.cheatmode.0=Режим рецептов nei.options.inventory.cheatmode.1=Режим полезностей nei.options.inventory.cheatmode.2=Чит-режим -nei.options.inventory.layoutstyle=Стиль расположения + nei.options.inventory.profileRecipes=Рецепты профиля nei.options.inventory.profileRecipes.true=Да nei.options.inventory.profileRecipes.false=Нет @@ -161,8 +161,8 @@ nei.options.tools.dump.itempanel.mode.3=PNG nei.options.tools.dump.itempanel.icon.dumped=Иконки панели предметов сохранены в %s nei.options.tools.dump.itempanel.icon.cancelled=Дамп отменён -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Старый TMI + + nei.recipe.page=Страница %s/%s nei.recipe.tooltip=Рецепты diff --git a/resources/assets/nei/lang/sk_SK.lang b/resources/assets/nei/lang/sk_SK.lang index 82526243..fe119ecf 100644 --- a/resources/assets/nei/lang/sk_SK.lang +++ b/resources/assets/nei/lang/sk_SK.lang @@ -84,7 +84,7 @@ nei.options.inventory.widgetsenabled.false=NEI zakázané nei.options.inventory.cheatmode.0=Mód Receptov nei.options.inventory.cheatmode.1=Úžitkový mód nei.options.inventory.cheatmode.2=Čítovací mód -nei.options.inventory.layoutstyle=Štýl rozmiestnenia + nei.options.inventory.profileRecipes=Profilovanie receptov nei.options.inventory.profileRecipes.true=Áno nei.options.inventory.profileRecipes.false=Nie @@ -153,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Staré TMI + + nei.recipe.page=Strana %s/%s nei.recipe.shaped=Tvarovaná výroba diff --git a/resources/assets/nei/lang/tr_TR.lang b/resources/assets/nei/lang/tr_TR.lang index 0f2027c8..05dd4ef5 100644 --- a/resources/assets/nei/lang/tr_TR.lang +++ b/resources/assets/nei/lang/tr_TR.lang @@ -84,7 +84,7 @@ nei.options.inventory.widgetsenabled.false=NEI Kapalı nei.options.inventory.cheatmode.0=Tarif modu nei.options.inventory.cheatmode.1=Yardımcı mod nei.options.inventory.cheatmode.2=Hileli mod -nei.options.inventory.layoutstyle=Tema + nei.options.inventory.profileRecipes=Profil tarifleri nei.options.inventory.profileRecipes.true=Yazı nei.options.inventory.profileRecipes.false=Şekil @@ -153,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft -nei.layoutstyle.oldtmi=Eski TMI + + nei.recipe.page=Sayfa %s/%s nei.recipe.shaped=Üretim diff --git a/resources/assets/nei/lang/zh_CN.lang b/resources/assets/nei/lang/zh_CN.lang index 433d9003..484fd112 100644 --- a/resources/assets/nei/lang/zh_CN.lang +++ b/resources/assets/nei/lang/zh_CN.lang @@ -84,7 +84,7 @@ nei.options.inventory.widgetsenabled.false=禁用NEI nei.options.inventory.cheatmode.0=合成模式 nei.options.inventory.cheatmode.1=实用模式 nei.options.inventory.cheatmode.2=作弊模式 -nei.options.inventory.layoutstyle=界面风格 + nei.options.inventory.profileRecipes=合成查阅性能分析 nei.options.inventory.profileRecipes.true=开启 nei.options.inventory.profileRecipes.false=关闭 @@ -153,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft风格 -nei.layoutstyle.oldtmi=老式TMI风格 + + nei.recipe.page=页数 %s/%s nei.recipe.shaped=有序合成 diff --git a/resources/assets/nei/lang/zh_TW.lang b/resources/assets/nei/lang/zh_TW.lang index 0c8fe608..3b016a75 100644 --- a/resources/assets/nei/lang/zh_TW.lang +++ b/resources/assets/nei/lang/zh_TW.lang @@ -84,7 +84,7 @@ nei.options.inventory.widgetsenabled.false=NEI關閉 nei.options.inventory.cheatmode.0=合成模式 nei.options.inventory.cheatmode.1=實用模式 nei.options.inventory.cheatmode.2=作弊模式 -nei.options.inventory.layoutstyle=界面風格 + nei.options.inventory.profileRecipes=合成查詢 nei.options.inventory.profileRecipes.true=開啟 nei.options.inventory.profileRecipes.false=關閉 @@ -153,8 +153,8 @@ nei.options.tools.dump.itempanel.mode.0=CSV nei.options.tools.dump.itempanel.mode.1=NBT nei.options.tools.dump.itempanel.mode.2=Json -nei.layoutstyle.minecraft=Minecraft風格 -nei.layoutstyle.oldtmi=舊TMI風格 + + nei.recipe.page=頁數 %s/%s nei.recipe.shaped=成型工藝 diff --git a/src/codechicken/nei/BookmarkPanel.java b/src/codechicken/nei/BookmarkPanel.java new file mode 100644 index 00000000..2da7d728 --- /dev/null +++ b/src/codechicken/nei/BookmarkPanel.java @@ -0,0 +1,137 @@ +package codechicken.nei; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/* + * TODO: + * 1) Bookmark button to toggle visibility + */ +public class BookmarkPanel extends ItemPanel { + + public void init() { + super.init(); + } + + public String getLabelText() { + return super.getLabelText() + " [" + items.size() + "]"; + } + + public void addOrRemoveItem(ItemStack item) { + ItemStack normalized = normalize(item); + if(!remove(normalized)) { + _items.add(normalized); + } + saveBookmarks(); + } + + public void saveBookmarks() { + List strings = new ArrayList<>(); + for (ItemStack item:_items) { + strings.add(item.writeToNBT(new NBTTagCompound()).toString()); + } + File file = NEIClientConfig.bookmarkFile; + if(file != null) { + try(FileWriter writer = new FileWriter(file)) { + IOUtils.writeLines(strings, "\n", writer); + } catch (IOException e) { + NEIClientConfig.logger.error("Filed to save bookmarks list to file {}", file, e); + } + } + } + + public void loadBookmarks() { + File file = NEIClientConfig.bookmarkFile; + if (file == null || !file.exists()) { + return; + } + List itemStrings; + try (FileReader reader = new FileReader(file)) { + NEIClientConfig.logger.info("Loading bookmarks from file {}", file); + itemStrings = IOUtils.readLines(reader); + } catch (IOException e) { + NEIClientConfig.logger.error("Failed to load bookmarks from file {}", file, e); + return; + } + _items.clear(); + for (String itemStr: itemStrings) { + try { + NBTTagCompound itemStackNBT = (NBTTagCompound)JsonToNBT.func_150315_a(itemStr); + ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemStackNBT); + if (itemStack != null) { + _items.add(itemStack); + } else { + NEIClientConfig.logger.warn("Failed to load bookmarked ItemStack from json string, the item no longer exists:\n{}", itemStr); + } + } catch (NBTException e) { + NEIClientConfig.logger.error("Failed to load bookmarked ItemStack from json string:\n{}", itemStr, e); + } + } + } + + protected ItemStack normalize(ItemStack item) { + ItemStack copy = item.copy(); + copy.stackSize = 1; + return copy; + } + private boolean remove(ItemStack item) { + int i = 0; + for (ItemStack existing : _items) { + if (existing == item || existing.isItemEqual(item)) { + _items.remove(i); + return true; + } + i++; + } + return false; + } + + + @Override + public int getMarginLeft() { + return 5; + } + + + @Override + public int getButtonTop() { + LayoutStyleMinecraft layout = (LayoutStyleMinecraft)LayoutManager.getLayoutStyle(); + return 2 + (((int)Math.ceil((double)layout.buttonCount / layout.numButtons)) * 18); + } + + @Override + public int getNextX(GuiContainer gui) { + return gui.width - prev.w - 2 - ((gui.xSize + gui.width) /2 + 2); + } + + @Override + public int getPrevX(GuiContainer gui) { + return 2; + } + + @Override + public int getPageX(GuiContainer gui) { + return gui.guiLeft * 3 / 2 + gui.xSize + 1 - ((gui.xSize + gui.width) /2 + 2); + } + + public int getHightAdjustment() { + return 0; + } + + public int getWidth(GuiContainer gui) { + return LayoutManager.getLeftSize(gui) - x; + + } + +} diff --git a/src/codechicken/nei/Image.java b/src/codechicken/nei/Image.java index 5634a4f7..4fb746a6 100644 --- a/src/codechicken/nei/Image.java +++ b/src/codechicken/nei/Image.java @@ -7,11 +7,11 @@ public class Image public int width; public int height; - public Image(int i, int j, int k, int l) + public Image(int x, int y, int w, int h) { - x = i; - y = j; - width = k; - height = l; + this.x = x; + this.y = y; + width = w; + height = h; } } diff --git a/src/codechicken/nei/ItemList.java b/src/codechicken/nei/ItemList.java index fac8434c..4ffdba8b 100644 --- a/src/codechicken/nei/ItemList.java +++ b/src/codechicken/nei/ItemList.java @@ -22,7 +22,7 @@ public class ItemList /** * Fields are replaced atomically and contents never modified. */ - public static volatile List items = new ArrayList(); + public static volatile List items = new ArrayList(); /** * Fields are replaced atomically and contents never modified. */ @@ -233,17 +233,21 @@ public class ItemList public void execute() { ArrayList filtered = new ArrayList(); ItemFilter filter = getItemListFilter(); - for(ItemStack item : items) { + + items.parallelStream().forEach(item -> { if (interrupted()) return; - if(filter.matches(item)) - filtered.add(item); - } + if(filter.matches(item)) { + synchronized (filtered){ + filtered.add(item); + } + } + }); if(interrupted()) return; ItemSorter.sort(filtered); if(interrupted()) return; - ItemPanel.updateItemList(filtered); + ItemPanels.itemPanel.updateItemList(filtered); } }; diff --git a/src/codechicken/nei/ItemMobSpawner.java b/src/codechicken/nei/ItemMobSpawner.java index 21d04292..289401f7 100644 --- a/src/codechicken/nei/ItemMobSpawner.java +++ b/src/codechicken/nei/ItemMobSpawner.java @@ -17,10 +17,8 @@ import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; public class ItemMobSpawner extends ItemBlock { @@ -129,11 +127,7 @@ public class ItemMobSpawner extends ItemBlock } } - for(Iterator> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) { - Entry e = it.next(); - if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig")) - it.remove(); - } + IDtoNameMap.entrySet().removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig")); } @Override diff --git a/src/codechicken/nei/ItemPanel.java b/src/codechicken/nei/ItemPanel.java index 6943bcde..00d13f4c 100644 --- a/src/codechicken/nei/ItemPanel.java +++ b/src/codechicken/nei/ItemPanel.java @@ -14,19 +14,23 @@ import net.minecraft.item.ItemStack; import java.util.ArrayList; import static codechicken.lib.gui.GuiDraw.drawRect; +import static codechicken.nei.NEIClientConfig.canPerformAction; -public class ItemPanel extends Widget -{ +public class ItemPanel extends Widget { /** * Should not be externally modified, use updateItemList */ - public static ArrayList items = new ArrayList(); + public ArrayList items = new ArrayList(); /** * Swapped into visible items on update */ - private static ArrayList _items = items; + protected ArrayList _items = items; - public static void updateItemList(ArrayList newItems) { + public ArrayList getItems() { + return items; + } + + public void updateItemList(ArrayList newItems) { _items = newItems; } @@ -44,6 +48,11 @@ public class ItemPanel extends Widget public ItemStack draggedStack; public int mouseDownSlot = -1; + public Button prev; + public Button next; + public Label pageLabel; + + private int marginLeft; private int marginTop; private int rows; @@ -56,11 +65,112 @@ public class ItemPanel extends Widget private int page; private int numPages; - public void resize() { - items = _items; - marginLeft = x + (w % 18) / 2; - marginTop = y + (h % 18) / 2; + + public void init() { + pageLabel = new Label("(0/0)", true); + + prev = new Button("Prev") + { + public boolean onButtonPress(boolean rightclick) { + if (!rightclick) { + scroll(-1); + return true; + } + return false; + } + + @Override + public String getRenderLabel() { + return "<"; + } + }; + next = new Button("Next") + { + public boolean onButtonPress(boolean rightclick) { + if (!rightclick) { + scroll(1); + return true; + } + return false; + } + + @Override + public String getRenderLabel() { + return ">"; + } + }; + } + + public int getMarginLeft() { + return x + (w % 18) / 2; + } + + public int getMarginTop() { + return y + (h % 18) / 2; + } + + public int getButtonTop() { + return 2; + } + + public int getNextX(GuiContainer gui) { + return gui.width - prev.w - 2; + } + + public int getPrevX(GuiContainer gui) { + return (gui.xSize + gui.width) / 2 + 2; + } + + public int getPageX(GuiContainer gui) { + return gui.guiLeft * 3 / 2 + gui.xSize + 1; + } + + public int getHeight(GuiContainer gui) { + return gui.height - 15 - y + getHightAdjustment(); + } + + public int getHightAdjustment() { + int hAdj = 0; + if (!canPerformAction("item")) + hAdj += 15; + return hAdj; + } + + public int getWidth(GuiContainer gui) { + return LayoutManager.getSideWidth(gui) - x; + } + + public String getLabelText() { + return pageLabel.text = "(" + getPage() + "/" + getNumPages() + ")"; + } + + public void resize(GuiContainer gui) { + items = _items; + final int buttonHeight = 16; + final int buttonWidth = 16; + + prev.x = getPrevX(gui); + prev.y = getButtonTop(); + prev.h = buttonHeight; + prev.w = buttonWidth; + + next.x = getNextX(gui); + next.y = getButtonTop(); + next.h = buttonHeight; + next.w = buttonWidth; + + pageLabel.x = getPageX(gui); + pageLabel.y = prev.y + 5; + pageLabel.text = getLabelText(); + + y = prev.h + prev.y; + x = (gui.xSize + gui.width) / 2 + 3; + w = getWidth(gui); + h = getHeight(gui); + + marginLeft = getMarginLeft(); + marginTop = getMarginTop(); columns = w / 18; rows = h / 18; //sometimes width and height can be negative with certain resizing @@ -86,6 +196,12 @@ public class ItemPanel extends Widget page = firstIndex / itemsPerPage + 1; } + public void setVisible() { + LayoutManager.addWidget(prev); + LayoutManager.addWidget(next); + LayoutManager.addWidget(pageLabel); + + } private void updateValidSlots() { GuiContainer gui = NEIClientUtils.getGuiContainer(); validSlotMap = new boolean[rows * columns]; @@ -146,7 +262,7 @@ public class ItemPanel extends Widget @Override public void mouseDragged(int mousex, int mousey, int button, long heldTime) { if (mouseDownSlot >= 0 && draggedStack == null && NEIClientUtils.getHeldItem() == null && - NEIClientConfig.hasSMPCounterPart() && !GuiInfo.hasCustomSlots(NEIClientUtils.getGuiContainer())) { + NEIClientConfig.hasSMPCounterPart() && !GuiInfo.hasCustomSlots(NEIClientUtils.getGuiContainer())) { ItemPanelSlot mouseOverSlot = getSlotMouseOver(mousex, mousey); ItemStack stack = new ItemPanelSlot(mouseDownSlot).item; if (stack != null && (mouseOverSlot == null || mouseOverSlot.slotIndex != mouseDownSlot || heldTime > 500)) { diff --git a/src/codechicken/nei/ItemPanels.java b/src/codechicken/nei/ItemPanels.java new file mode 100644 index 00000000..ffecb678 --- /dev/null +++ b/src/codechicken/nei/ItemPanels.java @@ -0,0 +1,6 @@ +package codechicken.nei; + +public class ItemPanels { + public static ItemPanel itemPanel = new ItemPanel(); + public static BookmarkPanel bookmarkPanel = new BookmarkPanel(); +} diff --git a/src/codechicken/nei/ItemQuantityField.java b/src/codechicken/nei/ItemQuantityField.java index 5d5d9d3f..6ca23f69 100644 --- a/src/codechicken/nei/ItemQuantityField.java +++ b/src/codechicken/nei/ItemQuantityField.java @@ -7,7 +7,7 @@ public class ItemQuantityField extends TextField centered = true; } - @Override + // Find a way to work this this back in public boolean isValid(String string) { if (string.equals("")) return true; diff --git a/src/codechicken/nei/ItemSorter.java b/src/codechicken/nei/ItemSorter.java index 53d24e1a..cc4e82f2 100644 --- a/src/codechicken/nei/ItemSorter.java +++ b/src/codechicken/nei/ItemSorter.java @@ -10,7 +10,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; public class ItemSorter implements Comparator, ItemsLoadedCallback { @@ -44,7 +47,8 @@ public class ItemSorter implements Comparator, ItemsLoadedCallback public static void sort(ArrayList items) { try { - Collections.sort(items, instance); +// items = (ArrayList) items.parallelStream().sorted(instance).collect(Collectors.toList()); + items.sort(instance); } catch (Exception e) { NEIClientConfig.logger.error("Exception sorting item list", e); } diff --git a/src/codechicken/nei/Label.java b/src/codechicken/nei/Label.java index 2ba5e6e4..fbff8de9 100644 --- a/src/codechicken/nei/Label.java +++ b/src/codechicken/nei/Label.java @@ -7,7 +7,7 @@ public class Label extends Widget { boolean centered; int colour; - String text; + public String text; public Label(String s, boolean center, int color) { diff --git a/src/codechicken/nei/LayoutManager.java b/src/codechicken/nei/LayoutManager.java index 431f9209..23577e7a 100644 --- a/src/codechicken/nei/LayoutManager.java +++ b/src/codechicken/nei/LayoutManager.java @@ -2,8 +2,18 @@ package codechicken.nei; import codechicken.lib.gui.GuiDraw; import codechicken.nei.KeyManager.IKeyStateTracker; -import codechicken.nei.api.*; -import codechicken.nei.guihook.*; +import codechicken.nei.api.API; +import codechicken.nei.api.GuiInfo; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.IRecipeOverlayRenderer; +import codechicken.nei.api.ItemInfo; +import codechicken.nei.api.LayoutStyle; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerDrawHandler; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerObjectHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import cpw.mods.fml.common.Loader; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; @@ -12,16 +22,45 @@ import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import org.lwjgl.opengl.GL11; import java.util.HashMap; import java.util.List; import java.util.TreeSet; -import static codechicken.lib.gui.GuiDraw.*; -import static codechicken.nei.NEIClientConfig.*; -import static codechicken.nei.NEIClientUtils.*; +import static codechicken.lib.gui.GuiDraw.changeTexture; +import static codechicken.lib.gui.GuiDraw.drawRect; +import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect; +import static codechicken.nei.NEIClientConfig.canPerformAction; +import static codechicken.nei.NEIClientConfig.disabledActions; +import static codechicken.nei.NEIClientConfig.getItemQuantity; +import static codechicken.nei.NEIClientConfig.getKeyBinding; +import static codechicken.nei.NEIClientConfig.getOptionList; +import static codechicken.nei.NEIClientConfig.getSearchExpression; +import static codechicken.nei.NEIClientConfig.hasSMPCounterPart; +import static codechicken.nei.NEIClientConfig.invCreativeMode; +import static codechicken.nei.NEIClientConfig.isEnabled; +import static codechicken.nei.NEIClientConfig.isHidden; +import static codechicken.nei.NEIClientConfig.showIDs; +import static codechicken.nei.NEIClientConfig.toggleBooleanSetting; +import static codechicken.nei.NEIClientConfig.world; +import static codechicken.nei.NEIClientUtils.controlKey; +import static codechicken.nei.NEIClientUtils.cycleGamemode; +import static codechicken.nei.NEIClientUtils.decreaseSlotStack; +import static codechicken.nei.NEIClientUtils.deleteEverything; +import static codechicken.nei.NEIClientUtils.deleteHeldItem; +import static codechicken.nei.NEIClientUtils.deleteItemsOfType; +import static codechicken.nei.NEIClientUtils.getGuiContainer; +import static codechicken.nei.NEIClientUtils.getHeldItem; +import static codechicken.nei.NEIClientUtils.getNextGamemode; +import static codechicken.nei.NEIClientUtils.healPlayer; +import static codechicken.nei.NEIClientUtils.isValidGamemode; +import static codechicken.nei.NEIClientUtils.setHourForward; +import static codechicken.nei.NEIClientUtils.setItemQuantity; +import static codechicken.nei.NEIClientUtils.shiftKey; +import static codechicken.nei.NEIClientUtils.toggleMagnetMode; +import static codechicken.nei.NEIClientUtils.toggleRaining; +import static codechicken.nei.NEIClientUtils.translate; public class LayoutManager implements IContainerInputHandler, IContainerTooltipHandler, IContainerDrawHandler, IContainerObjectHandler, IKeyStateTracker { @@ -38,21 +77,17 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH private static TreeSet controlWidgets; public static ItemPanel itemPanel; + public static BookmarkPanel bookmarkPanel; public static SubsetWidget dropDown; public static TextField searchField; public static Button options; + public static Button bookmarks; - public static Button prev; - public static Button next; - public static Label pageLabel; public static Button more; public static Button less; public static ItemQuantityField quantity; - public static SaveLoadButton[] stateButtons; - public static Button[] deleteButtons; - public static Button delete; public static ButtonCycled gamemode; public static Button rain; @@ -64,9 +99,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH public static HashMap layoutStyles = new HashMap(); + public static boolean ftbUtilsLoaded = false; + public static void load() { + ftbUtilsLoaded = Loader.isModLoaded("FTBU"); + API.addLayoutStyle(0, new LayoutStyleMinecraft()); - API.addLayoutStyle(1, new LayoutStyleTMIOld()); instance = new LayoutManager(); KeyManager.trackers.add(instance); @@ -93,6 +131,13 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH } } + public static int getSideWidth(GuiContainer gui) { + return gui.width - 3; + } + public static int getLeftSize(GuiContainer gui) { + return getSideWidth(gui) - (ftbUtilsLoaded ? 18 : 0); + } + @Override public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { if (isHidden()) @@ -263,7 +308,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH } private static void init() { - itemPanel = new ItemPanel(); + itemPanel = ItemPanels.itemPanel; + itemPanel.init(); + + bookmarkPanel = ItemPanels.bookmarkPanel; + bookmarkPanel.init(); + dropDown = new SubsetWidget(); searchField = new SearchField("search"); @@ -283,37 +333,19 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH return translate("inventory.options"); } }; - prev = new Button("Prev") + + bookmarks = new Button("Bookmarks") { + @Override public boolean onButtonPress(boolean rightclick) { - if (!rightclick) { - LayoutManager.itemPanel.scroll(-1); - return true; - } return false; } @Override public String getRenderLabel() { - return translate("inventory.prev"); + return translate("bookmark.toggle"); } }; - next = new Button("Next") - { - public boolean onButtonPress(boolean rightclick) { - if (!rightclick) { - LayoutManager.itemPanel.scroll(1); - return true; - } - return false; - } - - @Override - public String getRenderLabel() { - return translate("inventory.next"); - } - }; - pageLabel = new Label("(0/0)", true); more = new Button("+") { @Override @@ -350,43 +382,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH }; quantity = new ItemQuantityField("quantity"); - stateButtons = new SaveLoadButton[7]; - deleteButtons = new Button[7]; - - for (int i = 0; i < 7; i++) { - final int savestate = i; - stateButtons[i] = new SaveLoadButton("") - { - @Override - public boolean onButtonPress(boolean rightclick) { - if (isStateSaved(savestate)) - loadState(savestate); - else - saveState(savestate); - return true; - } - - @Override - public void onTextChange() { - NBTTagCompound statelist = global.nbt.getCompoundTag("statename"); - global.nbt.setTag("statename", statelist); - - statelist.setString("" + savestate, label); - global.saveNBT(); - } - }; - deleteButtons[i] = new Button("x") - { - @Override - public boolean onButtonPress(boolean rightclick) { - if (!rightclick) { - clearState(savestate); - return true; - } - return false; - } - }; - } delete = new Button() { @@ -599,12 +594,12 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH if (!visiblity.showNEI) return; + addWidget(options); if (visiblity.showItemPanel) { addWidget(itemPanel); - addWidget(prev); - addWidget(next); - addWidget(pageLabel); + itemPanel.setVisible(); + if (canPerformAction("item")) { addWidget(more); addWidget(less); @@ -612,18 +607,16 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH } } + if (visiblity.showBookmarkPanel) { + addWidget(bookmarkPanel); + bookmarkPanel.setVisible(); + } + if (visiblity.showSearchSection) { addWidget(dropDown); addWidget(searchField); } - if (canPerformAction("item") && hasSMPCounterPart() && visiblity.showStateButtons) { - for (int i = 0; i < 7; i++) { - addWidget(stateButtons[i]); - if (isStateSaved(i)) - addWidget(deleteButtons[i]); - } - } if (visiblity.showUtilityButtons) { if (canPerformAction("time")) { for (int i = 0; i < 4; i++) @@ -653,10 +646,10 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH } public static LayoutStyle getLayoutStyle() { - return getLayoutStyle(NEIClientConfig.getLayoutStyle()); + return getLayoutStyle(0); } - private static void addWidget(Widget widget) { + public static void addWidget(Widget widget) { drawWidgets.add(widget); controlWidgets.add(widget); } @@ -798,4 +791,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH if (KeyManager.keyStates.get("world.creative").down) gamemode.onButtonPress(false); } + } + diff --git a/src/codechicken/nei/LayoutStyleDefault.java b/src/codechicken/nei/LayoutStyleDefault.java deleted file mode 100644 index 7e553436..00000000 --- a/src/codechicken/nei/LayoutStyleDefault.java +++ /dev/null @@ -1,153 +0,0 @@ -package codechicken.nei; - -import codechicken.nei.api.LayoutStyle; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.nbt.NBTTagCompound; - -import static codechicken.lib.gui.GuiDraw.getStringWidth; -import static codechicken.nei.LayoutManager.*; -import static codechicken.nei.NEIClientConfig.*; - -public abstract class LayoutStyleDefault extends LayoutStyle -{ - @Override - public void layout(GuiContainer gui, VisiblityData visiblity) { - int windowWidth = gui.width; - int windowHeight = gui.height; - int containerWidth = gui.xSize; - int containerLeft = gui.guiLeft; - - reset(); - - prev.y = 2; - prev.h = 16; - prev.w = containerLeft / 3; - prev.x = (containerWidth + windowWidth) / 2 + 2; - next.x = windowWidth - prev.w - 2; - - next.y = prev.y; - next.w = prev.w; - next.h = prev.h; - pageLabel.x = containerLeft * 3 / 2 + containerWidth + 1; - pageLabel.y = prev.y + 5; - pageLabel.text = "(" + itemPanel.getPage() + "/" + itemPanel.getNumPages() + ")"; - - itemPanel.y = prev.h + prev.y; - itemPanel.x = (containerWidth + windowWidth) / 2 + 3; - itemPanel.w = windowWidth - 3 - itemPanel.x; - itemPanel.h = windowHeight - 15 - itemPanel.y; - if (!canPerformAction("item")) - itemPanel.h += 15; - itemPanel.resize(); - - more.w = more.h = less.w = less.h = 16; - less.x = prev.x; - more.x = windowWidth - less.w - 2; - more.y = less.y = windowHeight - more.h - 2; - - quantity.x = less.x + less.w + 2; - quantity.y = less.y; - quantity.w = more.x - quantity.x - 2; - quantity.h = less.h; - - options.x = isEnabled() ? 0 : 6; - options.y = isEnabled() ? windowHeight - 22 : windowHeight - 28; - options.w = 80; - options.h = 22; - - delete.state = 0x4; - if (NEIController.getDeleteMode()) - delete.state |= 1; - else if (!visiblity.enableDeleteMode) - delete.state |= 2; - - rain.state = 0x4; - if (disabledActions.contains("rain")) - rain.state |= 2; - else if (NEIClientUtils.isRaining()) - rain.state |= 1; - - gamemode.state = 0x4; - if (NEIClientUtils.getGamemode() != 0) { - gamemode.state |= 0x1; - gamemode.index = NEIClientUtils.getGamemode() - 1; - } else { - if (NEIClientUtils.isValidGamemode("creative")) - gamemode.index = 0; - else if (NEIClientUtils.isValidGamemode("creative+")) - gamemode.index = 1; - else if (NEIClientUtils.isValidGamemode("adventure")) - gamemode.index = 2; - } - - magnet.state = 0x4 | (getMagnetMode() ? 1 : 0); - - if (canPerformAction("delete")) - layoutButton(delete); - if (canPerformAction("rain")) - layoutButton(rain); - if (NEIClientUtils.isValidGamemode("creative") || - NEIClientUtils.isValidGamemode("creative+") || - NEIClientUtils.isValidGamemode("adventure")) - layoutButton(gamemode); - if (canPerformAction("magnet")) - layoutButton(magnet); - if (canPerformAction("time")) { - for (int i = 0; i < 4; i++) { - timeButtons[i].state = disabledActions.contains(NEIActions.timeZones[i]) ? 2 : 0; - layoutButton(timeButtons[i]); - } - } - if (canPerformAction("heal")) - layoutButton(heal); - - searchField.y = windowHeight - searchField.h - 2; - - dropDown.h = 20; - dropDown.w = prev.x - dropDown.x - 3; - searchField.h = 20; - searchField.w = 150; - searchField.x = (windowWidth - searchField.w) / 2; - - if (!visiblity.showItemSection) { - //TODO dropDown.setDropDown(0); - searchField.setFocus(false); - } - - int maxWidth = 0; - for (int i = 0; i < 7; i++) { - deleteButtons[i].w = 16; - deleteButtons[i].h = 16; - - NBTTagCompound statelist = global.nbt.getCompoundTag("statename"); - global.nbt.setTag("statename", statelist); - String name = statelist.getString("" + i); - if (statelist.getTag("" + i) == null) { - name = "" + (i + 1); - statelist.setString("" + i, name); - } - stateButtons[i].label = name; - stateButtons[i].saved = isStateSaved(i); - - int width = getStringWidth(stateButtons[i].getRenderLabel()) + 26; - if (width + 22 > containerLeft) - width = containerLeft - 22; - - if (width > maxWidth) - maxWidth = width; - } - - for (int i = 0; i < 7; i++) { - stateButtons[i].x = 0; - stateButtons[i].y = 58 + i * 22; - stateButtons[i].h = 20; - - stateButtons[i].x = 0; - stateButtons[i].w = maxWidth; - deleteButtons[i].x = stateButtons[i].w + 3; - deleteButtons[i].y = stateButtons[i].y + 2; - } - } - - public abstract void layoutButton(Button button); -} diff --git a/src/codechicken/nei/LayoutStyleMinecraft.java b/src/codechicken/nei/LayoutStyleMinecraft.java index 57d3a152..c535b2b3 100644 --- a/src/codechicken/nei/LayoutStyleMinecraft.java +++ b/src/codechicken/nei/LayoutStyleMinecraft.java @@ -1,14 +1,34 @@ package codechicken.nei; +import codechicken.nei.api.LayoutStyle; +import net.minecraft.client.gui.inventory.GuiContainer; import org.lwjgl.opengl.GL11; import static codechicken.lib.gui.GuiDraw.drawStringC; -import static codechicken.nei.LayoutManager.*; +import static codechicken.nei.LayoutManager.bookmarkPanel; +import static codechicken.nei.LayoutManager.delete; +import static codechicken.nei.LayoutManager.dropDown; +import static codechicken.nei.LayoutManager.gamemode; +import static codechicken.nei.LayoutManager.heal; +import static codechicken.nei.LayoutManager.itemPanel; +import static codechicken.nei.LayoutManager.less; +import static codechicken.nei.LayoutManager.magnet; +import static codechicken.nei.LayoutManager.more; +import static codechicken.nei.LayoutManager.options; +import static codechicken.nei.LayoutManager.quantity; +import static codechicken.nei.LayoutManager.rain; +import static codechicken.nei.LayoutManager.searchField; +import static codechicken.nei.LayoutManager.timeButtons; +import static codechicken.nei.NEIClientConfig.canPerformAction; +import static codechicken.nei.NEIClientConfig.disabledActions; +import static codechicken.nei.NEIClientConfig.getMagnetMode; +import static codechicken.nei.NEIClientConfig.isEnabled; -public class LayoutStyleMinecraft extends LayoutStyleDefault +public class LayoutStyleMinecraft extends LayoutStyle { - int stateButtonCount; - int clickButtonCount; + public int buttonCount; + public int leftSize; + public int numButtons; @Override public String getName() { @@ -18,38 +38,118 @@ public class LayoutStyleMinecraft extends LayoutStyleDefault @Override public void init() { delete.icon = new Image(144, 12, 12, 12); + rain.icon = new Image(120, 12, 12, 12); gamemode.icons[0] = new Image(132, 12, 12, 12); gamemode.icons[1] = new Image(156, 12, 12, 12); gamemode.icons[2] = new Image(168, 12, 12, 12); - rain.icon = new Image(120, 12, 12, 12); magnet.icon = new Image(180, 24, 12, 12); timeButtons[0].icon = new Image(132, 24, 12, 12); timeButtons[1].icon = new Image(120, 24, 12, 12); timeButtons[2].icon = new Image(144, 24, 12, 12); timeButtons[3].icon = new Image(156, 24, 12, 12); heal.icon = new Image(168, 24, 12, 12); - dropDown.x = 90; } @Override public void reset() { - stateButtonCount = clickButtonCount = 0; + buttonCount = 0; } @Override - public void layoutButton(Button button) { - if ((button.state & 0x4) != 0) { - button.x = 6 + stateButtonCount * 20; - button.y = 3; - stateButtonCount++; + public void layout(GuiContainer gui, VisiblityData visiblity) { + reset(); + + //leftSize = ((gui.width - gui.xSize) / 2) - 3; + leftSize = ItemPanels.bookmarkPanel.getWidth(gui); + numButtons = leftSize / 18; + + delete.state = 0x4; + if (NEIController.getDeleteMode()) + delete.state |= 1; + else if (!visiblity.enableDeleteMode) + delete.state |= 2; + + rain.state = 0x4; + if (disabledActions.contains("rain")) + rain.state |= 2; + else if (NEIClientUtils.isRaining()) + rain.state |= 1; + + gamemode.state = 0x4; + if (NEIClientUtils.getGamemode() != 0) { + gamemode.state |= 0x1; + gamemode.index = NEIClientUtils.getGamemode() - 1; } else { - button.x = 6 + (clickButtonCount % 4) * 20; - button.y = 3 + (1 + clickButtonCount / 4) * 18; - clickButtonCount++; + if (NEIClientUtils.isValidGamemode("creative")) + gamemode.index = 0; + else if (NEIClientUtils.isValidGamemode("creative+")) + gamemode.index = 1; + else if (NEIClientUtils.isValidGamemode("adventure")) + gamemode.index = 2; } + magnet.state = 0x4 | (getMagnetMode() ? 1 : 0); + + if (canPerformAction("delete")) + layoutButton(delete); + if (canPerformAction("rain")) + layoutButton(rain); + if (NEIClientUtils.isValidGamemode("creative") || + NEIClientUtils.isValidGamemode("creative+") || + NEIClientUtils.isValidGamemode("adventure")) + layoutButton(gamemode); + if (canPerformAction("magnet")) + layoutButton(magnet); + if (canPerformAction("time")) { + for (int i = 0; i < 4; i++) { + timeButtons[i].state = disabledActions.contains(NEIActions.timeZones[i]) ? 2 : 0; + layoutButton(timeButtons[i]); + } + } + if (canPerformAction("heal")) + layoutButton(heal); + + itemPanel.resize(gui); + bookmarkPanel.resize(gui); + + more.w = more.h = less.w = less.h = 16; + less.x = itemPanel.prev.x; + more.x = gui.width - less.w - 2; + more.y = less.y = gui.height - more.h - 2; + + quantity.x = less.x + less.w + 2; + quantity.y = less.y; + quantity.w = more.x - quantity.x - 2; + quantity.h = less.h; + + options.x = isEnabled() ? 0 : 6; + options.y = isEnabled() ? gui.height - 22 : gui.height - 28; + options.w = 80; + options.h = 22; + + searchField.y = gui.height - searchField.h - 2; + + dropDown.x = itemPanel.x - 150; + dropDown.h = 20; + dropDown.w = Math.min(itemPanel.prev.x - dropDown.x - 3, 100); + searchField.h = 20; + searchField.w = 150; + searchField.x = (gui.width - searchField.w) / 2; + + if (!visiblity.showItemSection) { + searchField.setFocus(false); + } + + } + + public void layoutButton(Button button) { + button.x = 6 + (buttonCount % numButtons) * 20; + button.y = 3 + (buttonCount / numButtons) * 18; + button.h = 17; button.w = button.contentWidth() + 6; + + buttonCount++; } @Override @@ -61,7 +161,7 @@ public class LayoutStyleMinecraft extends LayoutStyleDefault if ((b.state & 0x3) == 2) tex = 0; else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) ||//not a state button and mouseover - (b.state & 0x3) == 1)//state active + (b.state & 0x3) == 1)//state active tex = 2; else tex = 1; @@ -70,7 +170,7 @@ public class LayoutStyleMinecraft extends LayoutStyleDefault Image icon = b.getRenderIcon(); if (icon == null) { int colour = tex == 2 ? 0xffffa0 : - tex == 0 ? 0x601010 : 0xe0e0e0; + tex == 0 ? 0x601010 : 0xe0e0e0; drawStringC(b.getRenderLabel(), b.x + b.w / 2, b.y + (b.h - 8) / 2, colour); } else { diff --git a/src/codechicken/nei/LayoutStyleTMIOld.java b/src/codechicken/nei/LayoutStyleTMIOld.java deleted file mode 100644 index 325990eb..00000000 --- a/src/codechicken/nei/LayoutStyleTMIOld.java +++ /dev/null @@ -1,135 +0,0 @@ -package codechicken.nei; - -import codechicken.nei.guihook.GuiContainerManager; - -import static codechicken.lib.gui.GuiDraw.drawRect; -import static codechicken.lib.gui.GuiDraw.drawString; -import static codechicken.lib.gui.GuiDraw.drawStringC; -import static codechicken.nei.LayoutManager.*; - -public class LayoutStyleTMIOld extends LayoutStyleDefault -{ - public static final Image stateOff = new Image(48, 0, 8, 12); - public static final Image stateOn = new Image(56, 0, 8, 12); - public static final Image stateDisabled = new Image(64, 0, 8, 12); - - int stateButtonCount; - int clickButtonCount; - - @Override - public String getName() - { - return "oldtmi"; - } - - @Override - public void init() - { - delete.icon = new Image(24, 12, 12, 12); - gamemode.icons[0] = new Image(12, 12, 12, 12); - gamemode.icons[1] = new Image(36, 12, 12, 12); - gamemode.icons[2] = new Image(48, 12, 12, 12); - rain.icon = new Image(0, 12, 12, 12); - magnet.icon = new Image(60, 24, 12, 12); - timeButtons[0].icon = new Image(12, 24, 12, 12); - timeButtons[1].icon = new Image(0, 24, 12, 12); - timeButtons[2].icon = new Image(24, 24, 12, 12); - timeButtons[3].icon = new Image(36, 24, 12, 12); - heal.icon = new Image(48, 24, 12, 12); - dropDown.x = 93; - } - - @Override - public void reset() - { - stateButtonCount = clickButtonCount = 0; - } - - @Override - public void layoutButton(Button button) - { - int offsetx = 2; - int offsety = 2; - - if((button.state & 0x4) != 0) - { - button.x = offsetx + stateButtonCount*22; - button.y = offsety; - stateButtonCount++; - } - else - { - button.x = offsetx + (clickButtonCount%4)*22; - button.y = offsety + (1+clickButtonCount/4)*17; - clickButtonCount++; - } - - button.h = 14; - button.w = button.contentWidth() + 2; - if((button.state & 0x4) != 0) - button.w += stateOff.width; - } - - @Override - public void drawBackground(GuiContainerManager gui) - { - if(clickButtonCount == 0 && stateButtonCount == 0) - return; - - int maxx = Math.max(stateButtonCount, clickButtonCount); - if(maxx > 4)maxx = 4; - int maxy = clickButtonCount == 0 ? 1 : (clickButtonCount / 4 + 2); - - drawRect(0, 0, 2+22*maxx, 1+maxy*17, 0xFF000000); - } - - @Override - public void drawButton(Button b, int mousex, int mousey) - { - int cwidth = b.contentWidth(); - if((b.state & 0x4) != 0) - cwidth += stateOff.width; - int textx = b.x + (b.w - cwidth) / 2; - int texty = b.y + (b.h - 8) / 2; - - drawRect(b.x, b.y, b.w, b.h, b.contains(mousex, mousey) ? 0xee401008 : 0xee000000); - - Image icon = b.getRenderIcon(); - if(icon == null) - { - drawString(b.getRenderLabel(), textx, texty, -1); - } - else - { - int icony = b.y + (b.h - icon.height) / 2; - LayoutManager.drawIcon(textx, icony, icon); - if((b.state & 0x3) == 2) - drawRect(textx, icony, icon.width, icon.height, 0x80000000); - - if((b.state & 0x4) != 0) - { - Image stateimage; - if((b.state & 0x3) == 1) - stateimage = stateOn; - else if((b.state & 0x3) == 2) - stateimage = stateDisabled; - else - stateimage = stateOff; - LayoutManager.drawIcon(textx+icon.width, icony, stateimage); - } - } - } - - @Override - public void drawSubsetTag(String text, int x, int y, int w, int h, int state, boolean mouseover) { - drawRect(x, y, w, h, mouseover ? 0xFF401008 : 0xFF000000); - if(text != null) { - int colour = -1; - if (state == 0) - colour = 0xFF601010; - else if (state == 1) - colour = 0xFF807070; - drawStringC(text, x, y, w, h, colour, state == 0); - } - } -} diff --git a/src/codechicken/nei/NEIClientConfig.java b/src/codechicken/nei/NEIClientConfig.java index 5681657a..ec6e512d 100644 --- a/src/codechicken/nei/NEIClientConfig.java +++ b/src/codechicken/nei/NEIClientConfig.java @@ -1,19 +1,34 @@ package codechicken.nei; -import codechicken.core.*; +import codechicken.core.CCUpdateChecker; +import codechicken.core.ClassDiscoverer; +import codechicken.core.ClientUtils; +import codechicken.core.CommonUtils; import codechicken.lib.config.ConfigFile; import codechicken.lib.config.ConfigTag; import codechicken.lib.config.ConfigTagParent; -import codechicken.nei.api.*; -import codechicken.nei.config.*; +import codechicken.nei.api.API; +import codechicken.nei.api.GuiInfo; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.api.ItemInfo; +import codechicken.nei.api.NEIInfo; +import codechicken.nei.config.ConfigSet; +import codechicken.nei.config.GuiHighlightTips; +import codechicken.nei.config.GuiNEIOptionList; +import codechicken.nei.config.GuiOptionList; +import codechicken.nei.config.OptionCycled; +import codechicken.nei.config.OptionGamemodes; +import codechicken.nei.config.OptionList; +import codechicken.nei.config.OptionOpenGui; +import codechicken.nei.config.OptionTextField; +import codechicken.nei.config.OptionToggleButton; +import codechicken.nei.config.OptionUtilities; import codechicken.nei.recipe.RecipeInfo; import codechicken.obfuscator.ObfuscationRun; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.SaveFormatComparator; import org.apache.logging.log4j.LogManager; @@ -21,11 +36,8 @@ import org.apache.logging.log4j.Logger; import org.lwjgl.input.Keyboard; import java.io.File; -import java.util.Collections; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; -import java.util.Map.Entry; public class NEIClientConfig { @@ -38,9 +50,9 @@ public class NEIClientConfig new File("saves/NEI/client.dat"), new ConfigFile(new File(configDir, "client.cfg"))); public static ConfigSet world; + public static File bookmarkFile = new File(configDir, "bookmarks.ini"); - public static ItemStack creativeInv[]; - private static boolean statesSaved[] = new boolean[7]; + public static ItemStack[] creativeInv; public static boolean hasSMPCounterpart; public static HashSet permissableActions = new HashSet(); @@ -84,42 +96,6 @@ public class NEIClientConfig tag.getTag("inventory.gamemodes").setDefaultValue("creative, creative+, adventure"); API.addOption(new OptionGamemodes("inventory.gamemodes")); - tag.getTag("inventory.layoutstyle").getIntValue(0); - API.addOption(new OptionCycled("inventory.layoutstyle", 0) - { - @Override - public String getPrefix() { - return translateN(name); - } - - @Override - public String getButtonText() { - return NEIClientUtils.translate("layoutstyle." + - LayoutManager.getLayoutStyle(renderTag().getIntValue()).getName()); - } - - @Override - public boolean cycle() { - LinkedList list = new LinkedList(); - for (Entry entry : LayoutManager.layoutStyles.entrySet()) - list.add(entry.getKey()); - - Collections.sort(list); - - int nextLayout = renderTag().getIntValue(); - if (nextLayout == list.getLast())//loop list - nextLayout = -1; - for (Integer i : list) { - if (i > nextLayout) { - nextLayout = i; - break; - } - } - - getTag().setIntValue(nextLayout); - return true; - } - }); ItemSorter.initConfig(tag); @@ -186,6 +162,7 @@ public class NEIClientConfig API.addKeyBind("gui.next", Keyboard.KEY_NEXT); API.addKeyBind("gui.hide", Keyboard.KEY_O); API.addKeyBind("gui.search", Keyboard.KEY_F); + API.addKeyBind("gui.bookmark", Keyboard.KEY_A); API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9); API.addKeyBind("world.moboverlay", Keyboard.KEY_F7); API.addKeyBind("world.highlight_tips", Keyboard.KEY_NUMPAD0); @@ -252,23 +229,16 @@ public class NEIClientConfig if (configLoaded) return; - loadStates(); - //ItemVisibilityHash.loadStates(); - //vishash = new ItemVisibilityHash(); ItemInfo.load(world); GuiInfo.load(); RecipeInfo.load(); LayoutManager.load(); + ItemPanels.bookmarkPanel.loadBookmarks(); NEIController.load(); configLoaded = true; - ClassDiscoverer classDiscoverer = new ClassDiscoverer(new IStringMatcher() - { - public boolean matches(String test) { - return test.startsWith("NEI") && test.endsWith("Config.class"); - } - }, IConfigureNEI.class); + ClassDiscoverer classDiscoverer = new ClassDiscoverer(test -> test.startsWith("NEI") && test.endsWith("Config.class"), IConfigureNEI.class); classDiscoverer.findClasses(); @@ -286,21 +256,12 @@ public class NEIClientConfig ItemSorter.loadConfig(); } - public static void loadStates() { - for (int state = 0; state < 7; state++) - statesSaved[state] = !global.nbt.getCompoundTag("save" + state).hasNoTags(); - } - public static boolean isWorldSpecific(String setting) { if(world == null) return false; ConfigTag tag = world.config.getTag(setting, false); return tag != null && tag.value != null; } - public static boolean isStateSaved(int i) { - return statesSaved[i]; - } - public static ConfigTag getSetting(String s) { return isWorldSpecific(s) ? world.config.getTag(s) : global.config.getTag(s); } @@ -390,79 +351,6 @@ public class NEIClientConfig return hasSMPCounterPart() || getSetting("command.item").getValue().contains("{3}"); } - public static void clearState(int state) { - statesSaved[state] = false; - global.nbt.setTag("save" + state, new NBTTagCompound()); - global.saveNBT(); - } - - public static void loadState(int state) { - if (!statesSaved[state]) - return; - - NBTTagCompound statesave = global.nbt.getCompoundTag("save" + state); - GuiContainer currentContainer = NEIClientUtils.getGuiContainer(); - LinkedList saveAreas = new LinkedList(); - saveAreas.add(new TaggedInventoryArea(NEIClientUtils.mc().thePlayer.inventory)); - - for (INEIGuiHandler handler : GuiInfo.guiHandlers) { - List areaList = handler.getInventoryAreas(currentContainer); - if (areaList != null) - saveAreas.addAll(areaList); - } - - for (TaggedInventoryArea area : saveAreas) { - if (!statesave.hasKey(area.tagName)) - continue; - - for (int slot : area.slots) { - NEIClientUtils.setSlotContents(slot, null, area.isContainer()); - } - - NBTTagList areaTag = statesave.getTagList(area.tagName, 10); - for (int i = 0; i < areaTag.tagCount(); i++) { - NBTTagCompound stacksave = areaTag.getCompoundTagAt(i); - int slot = stacksave.getByte("Slot") & 0xFF; - if (!area.slots.contains(slot)) - continue; - - NEIClientUtils.setSlotContents(slot, ItemStack.loadItemStackFromNBT(stacksave), area.isContainer()); - } - } - } - - public static void saveState(int state) { - NBTTagCompound statesave = global.nbt.getCompoundTag("save" + state); - GuiContainer currentContainer = NEIClientUtils.getGuiContainer(); - LinkedList saveAreas = new LinkedList(); - saveAreas.add(new TaggedInventoryArea(NEIClientUtils.mc().thePlayer.inventory)); - - for (INEIGuiHandler handler : GuiInfo.guiHandlers) { - List areaList = handler.getInventoryAreas(currentContainer); - if (areaList != null) - saveAreas.addAll(areaList); - } - - for (TaggedInventoryArea area : saveAreas) { - NBTTagList areaTag = new NBTTagList(); - - for (int i : area.slots) { - ItemStack stack = area.getStackInSlot(i); - if (stack == null) - continue; - NBTTagCompound stacksave = new NBTTagCompound(); - stacksave.setByte("Slot", (byte) i); - stack.writeToNBT(stacksave); - areaTag.appendTag(stacksave); - } - statesave.setTag(area.tagName, areaTag); - } - - global.nbt.setTag("save" + state, statesave); - global.saveNBT(); - statesSaved[state] = true; - } - public static boolean hasSMPCounterPart() { return hasSMPCounterpart; } @@ -494,10 +382,7 @@ public class NEIClientConfig return false; String cmd = getStringSetting("command." + base); - if (cmd == null || !cmd.startsWith("/")) - return false; - - return true; + return cmd != null && cmd.startsWith("/"); } private static boolean modePermitsAction(String name) { diff --git a/src/codechicken/nei/NEIClientUtils.java b/src/codechicken/nei/NEIClientUtils.java index df0a8301..469a0ec9 100644 --- a/src/codechicken/nei/NEIClientUtils.java +++ b/src/codechicken/nei/NEIClientUtils.java @@ -22,9 +22,20 @@ import org.lwjgl.input.Keyboard; import java.text.MessageFormat; import java.text.NumberFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; -import static codechicken.nei.NEIClientConfig.*; +import static codechicken.nei.NEIClientConfig.canCheatItem; +import static codechicken.nei.NEIClientConfig.canPerformAction; +import static codechicken.nei.NEIClientConfig.getItemQuantity; +import static codechicken.nei.NEIClientConfig.getStringArrSetting; +import static codechicken.nei.NEIClientConfig.getStringSetting; +import static codechicken.nei.NEIClientConfig.hasSMPCounterPart; +import static codechicken.nei.NEIClientConfig.invCreativeMode; +import static codechicken.nei.NEIClientConfig.world; public class NEIClientUtils extends NEIServerUtils { diff --git a/src/codechicken/nei/SaveLoadButton.java b/src/codechicken/nei/SaveLoadButton.java deleted file mode 100644 index 5b589cd0..00000000 --- a/src/codechicken/nei/SaveLoadButton.java +++ /dev/null @@ -1,120 +0,0 @@ -package codechicken.nei; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.ChatAllowedCharacters; -import org.lwjgl.input.Keyboard; - -import static codechicken.lib.gui.GuiDraw.drawString; -import static codechicken.lib.gui.GuiDraw.getStringWidth; -import static codechicken.nei.NEIClientUtils.translate; - -public abstract class SaveLoadButton extends Button -{ - public SaveLoadButton(String s) - { - super(s); - } - - @Override - public boolean handleClick(int mousex, int mousey, int button) - { - if(button == 1) - { - label = ""; - onTextChange(); - focused = true; - NEIClientUtils.playClickSound(); - return true; - } - return super.handleClick(mousex, mousey, button); - } - - public abstract void onTextChange(); - - @Override - public void onGuiClick(int i, int j) - { - if(!contains(i, j)) - focused = false; - } - - @Override - public boolean handleKeyPress(int keyID, char keyChar) - { - if(!focused) - return false; - - if(keyID == Keyboard.KEY_BACK) - { - if(label.length() > 0) - { - label = label.substring(0, label.length() - 1); - onTextChange(); - backdowntime = System.currentTimeMillis(); - } - } - else if(keyID == Keyboard.KEY_RETURN) - { - focused = false; - } - else if(keyChar == 22)//paste - { - String pastestring = GuiScreen.getClipboardString(); - if(pastestring == null) - pastestring = ""; - - label = label + pastestring; - onTextChange(); - } - else if(ChatAllowedCharacters.isAllowedCharacter(keyChar)) - { - label = label + keyChar; - onTextChange(); - } - return true; - } - - @Override - public void update() - { - cursorCounter++; - if(backdowntime > 0) - { - if(Keyboard.isKeyDown(Keyboard.KEY_BACK) && label.length() > 5) - { - if(System.currentTimeMillis() - backdowntime > 200 / (1+backs * 0.3F)) - { - label = label.substring(0, label.length() - 1); - onTextChange(); - backdowntime = System.currentTimeMillis(); - backs++; - } - } - else - { - backdowntime = 0; - backs = 0; - } - } - } - - @Override - public void draw(int mousex, int mousey) - { - super.draw(mousex, mousey); - if(focused && (cursorCounter / 6) % 2 == 0) - drawString("_", x + (w + getStringWidth(getRenderLabel())) / 2, y + (h - 8) / 2, 0xFFFFFFFF); - } - - @Override - public String getRenderLabel() - { - return translate(saved ? "load" : "save") + " " + label; - } - - public boolean saved; - public long backdowntime; - public int backs; - public int cursorCounter; - public boolean focused; -} diff --git a/src/codechicken/nei/SearchField.java b/src/codechicken/nei/SearchField.java index e00049a0..a86e2e60 100644 --- a/src/codechicken/nei/SearchField.java +++ b/src/codechicken/nei/SearchField.java @@ -1,5 +1,6 @@ package codechicken.nei; +import codechicken.lib.gui.GuiDraw; import codechicken.nei.ItemList.AnyMultiItemFilter; import codechicken.nei.ItemList.EverythingItemFilter; import codechicken.nei.ItemList.PatternItemFilter; @@ -13,8 +14,6 @@ import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import static codechicken.lib.gui.GuiDraw.drawGradientRect; -import static codechicken.lib.gui.GuiDraw.drawRect; import static codechicken.nei.NEIClientConfig.world; public class SearchField extends TextField implements ItemFilterProvider @@ -64,18 +63,32 @@ public class SearchField extends TextField implements ItemFilterProvider } @Override - public void drawBox() { - if (searchInventories()) - drawGradientRect(x, y, w, h, 0xFFFFFF00, 0xFFC0B000); - else - drawRect(x, y, w, h, 0xffA0A0A0); - drawRect(x + 1, y + 1, w - 2, h - 2, 0xFF000000); + public int getTextColour() { + if(ItemPanels.itemPanel.items.size() == 0) { + return focused() ? 0xFFcc3300 : 0xFF993300; + } else { + return focused() ? 0xFFE0E0E0 : 0xFF909090; + } + } + + @Override + public void draw(int mousex, int mousey) { + + super.draw(mousex, mousey); + + if (searchInventories()) { + GuiDraw.drawGradientRect(x - 1, y - 1, 1, h + 2, 0xFFFFFF00, 0xFFC0B000); //Left + GuiDraw.drawGradientRect(x - 1, y - 1, w + 2, 1, 0xFFFFFF00, 0xFFC0B000); //Top + GuiDraw.drawGradientRect(x + w, y - 1, 1, h + 2, 0xFFFFFF00, 0xFFC0B000); //Left + GuiDraw.drawGradientRect(x - 1, y + h, w + 2, 1, 0xFFFFFF00, 0xFFC0B000); //Bottom + } + } @Override public boolean handleClick(int mousex, int mousey, int button) { if (button == 0) { - if (focused() && (System.currentTimeMillis() - lastclicktime < 500)) {//double click + if (focused() && (System.currentTimeMillis() - lastclicktime < 400)) { //double click NEIClientConfig.world.nbt.setBoolean("searchinventories", !searchInventories()); NEIClientConfig.world.saveNBT(); } @@ -86,7 +99,11 @@ public class SearchField extends TextField implements ItemFilterProvider @Override public void onTextChange(String oldText) { - NEIClientConfig.setSearchExpression(text()); + final String newText = text(); + if( newText.length() > 0) + NEIClientConfig.logger.info("Searching for " + text()); + + NEIClientConfig.setSearchExpression(newText); ItemList.updateFilter.restart(); } diff --git a/src/codechicken/nei/SubsetWidget.java b/src/codechicken/nei/SubsetWidget.java index 7db14afa..42f34056 100644 --- a/src/codechicken/nei/SubsetWidget.java +++ b/src/codechicken/nei/SubsetWidget.java @@ -18,9 +18,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; -import java.awt.*; -import java.util.*; +import java.awt.Point; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Pattern; @@ -58,7 +63,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa if(slot < sorted.size()) { SubsetTag tag = sorted.get(slot); if (NEIClientUtils.shiftKey()) - LayoutManager.searchField.setText("@" + tag.fullname); + codechicken.nei.LayoutManager.searchField.setText("@" + tag.fullname); else if (button == 0 && count >= 2) SubsetWidget.showOnly(tag); else @@ -78,7 +83,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot)); if(slot < sorted.size()) { SubsetTag tag = sorted.get(slot); - LayoutManager.getLayoutStyle().drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my)); + codechicken.nei.LayoutManager.getLayoutStyle().drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my)); } else { ItemStack stack = state.items.get(slot-sorted.size()); @@ -87,7 +92,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa int itemx = w/2-8; int itemy = 1; - LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false); + codechicken.nei.LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false); GuiContainerManager.drawItem(x+itemx, y+itemy, stack); if(new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my)) @@ -696,13 +701,10 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa @Override public ItemFilter getFilter() { - return new ItemFilter()//synchronise access on hiddenItems - { - @Override - public boolean matches(ItemStack item) { - synchronized (hiddenItems) { - return !hiddenItems.matches(item); - } + //synchronise access on hiddenItems + return item -> { + synchronized (hiddenItems) { + return !hiddenItems.matches(item); } }; } diff --git a/src/codechicken/nei/TextField.java b/src/codechicken/nei/TextField.java index c1c32ed9..f5f9fb2c 100644 --- a/src/codechicken/nei/TextField.java +++ b/src/codechicken/nei/TextField.java @@ -1,43 +1,44 @@ package codechicken.nei; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.ChatAllowedCharacters; +import cpw.mods.fml.client.config.HoverChecker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiTextField; import org.lwjgl.input.Keyboard; -import static codechicken.lib.gui.GuiDraw.*; - public abstract class TextField extends Widget { + protected GuiTextField field; + protected final HoverChecker hoverChecker; + + private static final int maxSearchLength = 256; + + public boolean centered; + public String identifier; + + private boolean previousKeyboardRepeatEnabled; + public TextField(String ident) { identifier = ident; + field = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 0, 0); + field.setMaxStringLength(maxSearchLength); + this.hoverChecker = new HoverChecker(0, 0, 0, 0, 0); + field.setCursorPositionZero(); +// Keyboard.enableRepeatEvents(true); } public int getTextColour() { return focused() ? 0xFFE0E0E0 : 0xFF909090; } - public void drawBox() { - drawRect(x, y, w, h, 0xffA0A0A0); - drawRect(x + 1, y + 1, w - 2, h - 2, 0xFF000000); - } - @Override public void draw(int mousex, int mousey) { - drawBox(); + field.xPosition = this.x + 2; + field.yPosition = this.y + 2; + field.width = this.w - 4; + field.height = this.h - 4; + field.setTextColor(getTextColour()); - String drawtext = text; - - int textWidth; - while((textWidth = getStringWidth(drawtext)) > w - 14) - drawtext = drawtext.substring(1); - - if (focused() && (cursorCounter / 6) % 2 == 0) - drawtext = drawtext + '_'; - - int textx = centered ? x + (w - textWidth) / 2 : x + 4; - int texty = y + (h + 1) / 2 - 3; - - drawString(drawtext, textx, texty, getTextColour()); + field.drawTextBox(); } @Override @@ -48,9 +49,13 @@ public abstract class TextField extends Widget @Override public boolean handleClick(int mousex, int mousey, int button) { + setFocus(true); + if (button == 1) setText(""); - setFocus(true); + else + field.mouseClicked(mousex, mousey, button); + return true; } @@ -59,58 +64,32 @@ public abstract class TextField extends Widget if (!focused()) return false; - if (keyID == Keyboard.KEY_BACK) { - if (text.length() > 0) { - setText(text.substring(0, text.length() - 1)); - backdowntime = System.currentTimeMillis(); + boolean handled = field.textboxKeyTyped(keyChar, keyID); + if(!handled) { + if (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER || keyID == Keyboard.KEY_ESCAPE) { + setFocus(false); + handled = true; } - } else if (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_ESCAPE) { - setFocus(false); - onExit(); - } else if (keyChar == 22)//paste - { - String pastestring = GuiScreen.getClipboardString(); - if (pastestring == null) - pastestring = ""; + } - if (isValid(text + pastestring)) - setText(text + pastestring); - } else if (isValid(text + keyChar)) - setText(text + keyChar); + if(handled) { + onTextChange(text()); + } - return true; - } + return handled; - public void onExit() { } public abstract void onTextChange(String oldText); - public boolean isValid(String string) { - // Solve the problem that Minecraft can't post Chinese characters - return ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length() - 1)); - } - @Override public void update() { - cursorCounter++; - if (backdowntime > 0) { - if (Keyboard.isKeyDown(Keyboard.KEY_BACK) && text.length() > 0) { - if (System.currentTimeMillis() - backdowntime > 200 / (1 + backs * 0.3F)) { - setText(text.substring(0, text.length() - 1)); - backdowntime = System.currentTimeMillis(); - backs++; - } - } else { - backdowntime = 0; - backs = 0; - } - } } public void setText(String s) { - String oldText = text; - text = filterText(s); + String oldText = text(); + field.setText(s); + field.setCursorPositionZero(); onTextChange(oldText); } @@ -119,25 +98,26 @@ public abstract class TextField extends Widget } public void setFocus(boolean focus) { - if (focus) { - LayoutManager.setInputFocused(this); - } else if (focused()) { - LayoutManager.setInputFocused(null); + final boolean previousFocus = field.isFocused(); + field.setFocused(focus); + + if (previousFocus != focus) { + if (focus) { + previousKeyboardRepeatEnabled = Keyboard.areRepeatEventsEnabled(); + Keyboard.enableRepeatEvents(true); + } else { + Keyboard.enableRepeatEvents(previousKeyboardRepeatEnabled); + } + } } public boolean focused() { - return LayoutManager.getInputFocused() == this; + return field.isFocused(); } public String text() { - return text; + return field.getText(); } - private String text = ""; - public boolean centered; - public long backdowntime; - public int backs; - public String identifier; - public int cursorCounter; } diff --git a/src/codechicken/nei/VisiblityData.java b/src/codechicken/nei/VisiblityData.java index f5753aa8..5d0a23b5 100644 --- a/src/codechicken/nei/VisiblityData.java +++ b/src/codechicken/nei/VisiblityData.java @@ -3,11 +3,14 @@ package codechicken.nei; public class VisiblityData { public boolean showUtilityButtons = true; - public boolean showStateButtons = true; /** * Item panel and associated buttons */ public boolean showItemPanel = true; + /** + * Bookmark panel and associated buttons + */ + public boolean showBookmarkPanel = true; /** * Item and search section */ @@ -31,8 +34,8 @@ public class VisiblityData if(!showNEI) showWidgets = false; if(!showWidgets) - showItemSection = showUtilityButtons = showStateButtons = false; + showItemSection = showUtilityButtons = false; if(!showItemSection) - showSearchSection = showItemPanel = false; + showBookmarkPanel = showSearchSection = showItemPanel = false; } } diff --git a/src/codechicken/nei/api/API.java b/src/codechicken/nei/api/API.java index 6da0291c..c1103af6 100644 --- a/src/codechicken/nei/api/API.java +++ b/src/codechicken/nei/api/API.java @@ -1,13 +1,25 @@ package codechicken.nei.api; -import codechicken.nei.*; +import codechicken.nei.ItemList; +import codechicken.nei.ItemSorter; +import codechicken.nei.ItemStackSet; +import codechicken.nei.KeyManager; import codechicken.nei.KeyManager.KeyState; +import codechicken.nei.LayoutManager; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.OffsetPositioner; +import codechicken.nei.SearchField; import codechicken.nei.SearchField.ISearchProvider; +import codechicken.nei.SubsetWidget; import codechicken.nei.SubsetWidget.SubsetTag; import codechicken.nei.api.ItemFilter.ItemFilterProvider; import codechicken.nei.config.Option; import codechicken.nei.config.OptionKeyBind; -import codechicken.nei.recipe.*; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.ICraftingHandler; +import codechicken.nei.recipe.IUsageHandler; +import codechicken.nei.recipe.RecipeInfo; import net.minecraft.block.Block; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; diff --git a/src/codechicken/nei/config/GuiItemIconDumper.java b/src/codechicken/nei/config/GuiItemIconDumper.java index dae3ada5..8a0689cf 100644 --- a/src/codechicken/nei/config/GuiItemIconDumper.java +++ b/src/codechicken/nei/config/GuiItemIconDumper.java @@ -2,7 +2,7 @@ package codechicken.nei.config; import codechicken.core.CommonUtils; import codechicken.lib.gui.GuiDraw; -import codechicken.nei.ItemPanel; +import codechicken.nei.ItemPanels; import codechicken.nei.NEIClientConfig; import codechicken.nei.NEIClientUtils; import codechicken.nei.guihook.GuiContainerManager; @@ -22,7 +22,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import javax.imageio.ImageIO; -import java.awt.*; +import java.awt.Dimension; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -100,10 +100,10 @@ public class GuiItemIconDumper extends GuiScreen GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1, 1, 1, 1); - for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) { + for(int i = 0; drawIndex < ItemPanels.itemPanel.items.size() && i < fit; drawIndex++, i++) { int x = i%cols * 18; int y = i/cols * 18; - GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex)); + GuiContainerManager.drawItem(x+1, y+1, ItemPanels.itemPanel.items.get(drawIndex)); } GL11.glFlush(); @@ -114,13 +114,13 @@ public class GuiItemIconDumper extends GuiScreen int rows = img.getHeight() / boxSize; int cols = img.getWidth() / boxSize; int fit = rows*cols; - for(int i = 0; parseIndex < ItemPanel.items.size() && i < fit; parseIndex++, i++) { + for(int i = 0; parseIndex < ItemPanels.itemPanel.items.size() && i < fit; parseIndex++, i++) { int x = i%cols * boxSize; int y = i/cols * boxSize; - exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanel.items.get(parseIndex)); + exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanels.itemPanel.items.get(parseIndex)); } - if(parseIndex >= ItemPanel.items.size()) + if(parseIndex >= ItemPanels.itemPanel.items.size()) returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.dumped", "dumps/itempanel_icons")); } diff --git a/src/codechicken/nei/config/GuiItemSorter.java b/src/codechicken/nei/config/GuiItemSorter.java index 56e7caaf..8e870fc9 100644 --- a/src/codechicken/nei/config/GuiItemSorter.java +++ b/src/codechicken/nei/config/GuiItemSorter.java @@ -1,13 +1,13 @@ package codechicken.nei.config; import codechicken.lib.math.MathHelper; -import codechicken.nei.*; +import codechicken.nei.ItemSorter; import codechicken.nei.ItemSorter.SortEntry; import codechicken.nei.LayoutManager; import net.minecraft.client.gui.GuiScreen; import org.lwjgl.opengl.GL11; -import java.awt.*; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; diff --git a/src/codechicken/nei/config/GuiNEIOptionList.java b/src/codechicken/nei/config/GuiNEIOptionList.java index 4bb6dcb0..7828eba5 100644 --- a/src/codechicken/nei/config/GuiNEIOptionList.java +++ b/src/codechicken/nei/config/GuiNEIOptionList.java @@ -1,17 +1,10 @@ package codechicken.nei.config; -import codechicken.core.gui.GuiCCButton; -import codechicken.nei.NEIClientConfig; -import net.minecraft.client.gui.GuiConfirmOpenLink; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiYesNoCallback; -import java.awt.*; -import java.net.URI; - public class GuiNEIOptionList extends GuiOptionList implements GuiYesNoCallback { - private GuiCCButton patreonButton; public GuiNEIOptionList(GuiScreen parent, OptionList optionList, boolean world) { super(parent, optionList, world); @@ -20,35 +13,20 @@ public class GuiNEIOptionList extends GuiOptionList implements GuiYesNoCallback @Override public void resize() { super.resize(); - patreonButton.x = width-73; - patreonButton.y = height-23; } @Override public void addWidgets() { super.addWidgets(); - add(patreonButton = new PatreonButton(0, 0, 70, 20).setActionCommand("patreon")); } @Override public void actionPerformed(String ident, Object... params) { - if (ident.equals("patreon")) { - GuiConfirmOpenLink gui = new GuiConfirmOpenLink(this, "patreon.com/cb", 0, true); - gui.func_146358_g(); - mc.displayGuiScreen(gui); - } else - super.actionPerformed(ident, params); + super.actionPerformed(ident, params); } @Override public void confirmClicked(boolean yes, int id) { - if(yes && id == 0) { - try { - Desktop.getDesktop().browse(new URI("http://patreon.com/cb")); - } catch (Exception e) { - NEIClientConfig.logger.error("Failed to open patreon page", e); - } - } mc.displayGuiScreen(this); } } diff --git a/src/codechicken/nei/config/GuiOptionList.java b/src/codechicken/nei/config/GuiOptionList.java index 0425bb9c..66b6cd58 100644 --- a/src/codechicken/nei/config/GuiOptionList.java +++ b/src/codechicken/nei/config/GuiOptionList.java @@ -6,19 +6,21 @@ import codechicken.core.gui.GuiScrollSlot; import codechicken.lib.vec.Rectangle4i; import codechicken.nei.LayoutManager; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiConfirmOpenLink; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiYesNoCallback; import org.lwjgl.opengl.GL11; -import java.awt.*; -import java.net.URI; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import static codechicken.lib.gui.GuiDraw.*; +import static codechicken.lib.gui.GuiDraw.drawMultilineTip; +import static codechicken.lib.gui.GuiDraw.drawStringC; +import static codechicken.lib.gui.GuiDraw.fontRenderer; +import static codechicken.lib.gui.GuiDraw.getMousePosition; import static net.minecraft.util.StatCollector.translateToLocal; public class GuiOptionList extends GuiScreenWidget @@ -35,8 +37,7 @@ public class GuiOptionList extends GuiScreenWidget @Override public void onAdded(GuiScreen s) { super.onAdded(s); - for (Option o : optionList.optionList) - options.add(o); + options.addAll(optionList.optionList); for (Option o : options) o.onAdded(this); } diff --git a/src/codechicken/nei/config/ItemPanelDumper.java b/src/codechicken/nei/config/ItemPanelDumper.java index 822e52bc..350742d7 100644 --- a/src/codechicken/nei/config/ItemPanelDumper.java +++ b/src/codechicken/nei/config/ItemPanelDumper.java @@ -2,7 +2,7 @@ package codechicken.nei.config; import codechicken.lib.inventory.InventoryUtils; import codechicken.lib.vec.Rectangle4i; -import codechicken.nei.ItemPanel; +import codechicken.nei.ItemPanels; import codechicken.nei.NEIClientUtils; import codechicken.nei.guihook.GuiContainerManager; import net.minecraft.client.Minecraft; @@ -36,7 +36,7 @@ public class ItemPanelDumper extends DataDumper @Override public Iterable dump(int mode) { LinkedList list = new LinkedList(); - for (ItemStack stack : ItemPanel.items) + for (ItemStack stack : ItemPanels.itemPanel.items) list.add(new String[]{ Item.itemRegistry.getNameForObject(stack.getItem()), Integer.toString(Item.getIdFromItem(stack.getItem())), @@ -123,7 +123,7 @@ public class ItemPanelDumper extends DataDumper public void dumpNBT(File file) throws IOException { NBTTagList list = new NBTTagList(); - for (ItemStack stack : ItemPanel.items) + for (ItemStack stack : ItemPanels.itemPanel.items) list.appendTag(stack.writeToNBT(new NBTTagCompound())); NBTTagCompound tag = new NBTTagCompound(); @@ -134,7 +134,7 @@ public class ItemPanelDumper extends DataDumper public void dumpJson(File file) throws IOException { PrintWriter p = new PrintWriter(file); - for (ItemStack stack : ItemPanel.items) { + for (ItemStack stack : ItemPanels.itemPanel.items) { NBTTagCompound tag = stack.writeToNBT(new NBTTagCompound()); tag.removeTag("Count"); p.println(tag); diff --git a/src/codechicken/nei/config/OptionButton.java b/src/codechicken/nei/config/OptionButton.java index aba19594..38517117 100644 --- a/src/codechicken/nei/config/OptionButton.java +++ b/src/codechicken/nei/config/OptionButton.java @@ -4,10 +4,13 @@ import codechicken.nei.LayoutManager; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.awt.*; +import java.awt.Rectangle; import java.util.List; -import static codechicken.lib.gui.GuiDraw.*; +import static codechicken.lib.gui.GuiDraw.changeTexture; +import static codechicken.lib.gui.GuiDraw.drawString; +import static codechicken.lib.gui.GuiDraw.drawStringC; +import static codechicken.lib.gui.GuiDraw.getStringWidth; public abstract class OptionButton extends Option { diff --git a/src/codechicken/nei/config/OptionGamemodes.java b/src/codechicken/nei/config/OptionGamemodes.java index d4ffc3c6..0c189f64 100644 --- a/src/codechicken/nei/config/OptionGamemodes.java +++ b/src/codechicken/nei/config/OptionGamemodes.java @@ -18,8 +18,10 @@ public class OptionGamemodes extends OptionStringSet public void drawIcons() { int x = buttonX(); - LayoutManager.drawIcon(x+4, 4, new Image(132, 12, 12, 12)); x+=24; - LayoutManager.drawIcon(x+4, 4, new Image(156, 12, 12, 12)); x+=24; - LayoutManager.drawIcon(x+4, 4, new Image(168, 12, 12, 12)); x+=24; + LayoutManager.drawIcon(x+4, 4, new Image(132, 12, 12, 12)); + x+=24; + LayoutManager.drawIcon(x+4, 4, new Image(156, 12, 12, 12)); + x+=24; + LayoutManager.drawIcon(x+4, 4, new Image(168, 12, 12, 12)); } } diff --git a/src/codechicken/nei/config/OptionStringSet.java b/src/codechicken/nei/config/OptionStringSet.java index bd4c97ab..03499f00 100644 --- a/src/codechicken/nei/config/OptionStringSet.java +++ b/src/codechicken/nei/config/OptionStringSet.java @@ -5,7 +5,11 @@ import codechicken.nei.LayoutManager; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import static codechicken.lib.gui.GuiDraw.drawString; @@ -70,9 +74,9 @@ public abstract class OptionStringSet extends Option public boolean clickButton(int mousex, int mousey, int button) { int x = buttonX(); List values = values(); - for (int i = 0; i < options.size(); i++) { + for (String option : options) { if (new Rectangle4i(x, 0, 20, 20).contains(mousex, mousey)) { - String s = options.get(i); + String s = option; boolean set = values.contains(s); if (button == 0 && !set) { setValue(s); diff --git a/src/codechicken/nei/config/OptionTextField.java b/src/codechicken/nei/config/OptionTextField.java index 6bbef94c..48538a8c 100644 --- a/src/codechicken/nei/config/OptionTextField.java +++ b/src/codechicken/nei/config/OptionTextField.java @@ -14,15 +14,11 @@ public class OptionTextField extends Option private boolean focused = false; private TextField textField = new TextField("") { - @Override - public boolean isValid(String string) { - return super.isValid(string) && isValidInput(string); - } @Override public void onTextChange(String oldText) { if(focused() && isValidValue(text())) - if(!defaulting() || !text().equals(getTag().getValue()))//don't override global if text hasn't changed + if(!defaulting() || !text().equals(getTag().getValue())) //don't override global if text hasn't changed getTag().setValue(text()); } diff --git a/src/codechicken/nei/config/OptionUtilities.java b/src/codechicken/nei/config/OptionUtilities.java index 7d309866..a2004f62 100644 --- a/src/codechicken/nei/config/OptionUtilities.java +++ b/src/codechicken/nei/config/OptionUtilities.java @@ -44,8 +44,10 @@ public class OptionUtilities extends OptionStringSet GL11.glEnable(GL12.GL_RESCALE_NORMAL); ItemStack sword = new ItemStack(Items.diamond_sword); sword.addEnchantment(Enchantment.sharpness, 1); - GuiContainerManager.drawItem(x+2, 2, sword); x+=24; - GuiContainerManager.drawItem(x+2, 2, new ItemStack(Items.potionitem)); x+=24; - GuiContainerManager.drawItem(x+2, 2, new ItemStack(Blocks.stone)); x+=24; + GuiContainerManager.drawItem(x+2, 2, sword); + x+=24; + GuiContainerManager.drawItem(x+2, 2, new ItemStack(Items.potionitem)); + x+=24; + GuiContainerManager.drawItem(x+2, 2, new ItemStack(Blocks.stone)); } } diff --git a/src/codechicken/nei/config/PatreonButton.java b/src/codechicken/nei/config/PatreonButton.java deleted file mode 100644 index 1b32c54b..00000000 --- a/src/codechicken/nei/config/PatreonButton.java +++ /dev/null @@ -1,23 +0,0 @@ -package codechicken.nei.config; - -import codechicken.core.gui.GuiCCButton; -import codechicken.lib.render.CCRenderState; -import org.lwjgl.opengl.GL11; - -public class PatreonButton extends GuiCCButton -{ - public PatreonButton(int x, int y, int width, int height) { - super(x, y, width, height, null); - } - - @Override - public void drawButtonTex(int mousex, int mousey) { - super.drawButtonTex(mousex, mousey); - - GL11.glColor4f(1, 1, 1, 1); - CCRenderState.changeTexture("nei:textures/patreonNeon.png"); - int texh = height-4; - int texw = texh*4; - func_146110_a(x+width/2-texw/2, y+height/2-texh/2, 0, 0, texw, texh, texw, texh); - } -} diff --git a/src/codechicken/nei/recipe/GuiRecipe.java b/src/codechicken/nei/recipe/GuiRecipe.java index e80a3a92..97a6059d 100644 --- a/src/codechicken/nei/recipe/GuiRecipe.java +++ b/src/codechicken/nei/recipe/GuiRecipe.java @@ -2,8 +2,11 @@ package codechicken.nei.recipe; import codechicken.lib.gui.GuiDraw; import codechicken.lib.render.CCRenderState; -import codechicken.nei.*; +import codechicken.nei.GuiNEIButton; import codechicken.nei.LayoutManager; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIClientUtils; +import codechicken.nei.PositionedStack; import codechicken.nei.api.IGuiContainerOverlay; import codechicken.nei.api.IOverlayHandler; import codechicken.nei.api.IRecipeOverlayRenderer; @@ -17,7 +20,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; -import java.awt.*; +import java.awt.Point; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; diff --git a/src/codechicken/nei/recipe/RecipeItemInputHandler.java b/src/codechicken/nei/recipe/RecipeItemInputHandler.java index 3dd3e740..603b7945 100644 --- a/src/codechicken/nei/recipe/RecipeItemInputHandler.java +++ b/src/codechicken/nei/recipe/RecipeItemInputHandler.java @@ -1,5 +1,6 @@ package codechicken.nei.recipe; +import codechicken.nei.ItemPanels; import codechicken.nei.NEIClientConfig; import codechicken.nei.NEIClientUtils; import codechicken.nei.guihook.GuiContainerManager; @@ -21,7 +22,12 @@ public class RecipeItemInputHandler implements IContainerInputHandler if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) return GuiCraftingRecipe.openRecipeGui("item", stackover.copy()); - + + if(keyCode == NEIClientConfig.getKeyBinding("gui.bookmark")) { + NEIClientConfig.logger.debug("Adding or removing {} from bookmarks", stackover.getDisplayName()); + ItemPanels.bookmarkPanel.addOrRemoveItem(stackover.copy()); + } + return false; }