From 6d9ff9ea0adfd75b51a0706a7916718b983b906a Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Tue, 24 Dec 2019 13:37:41 -0800 Subject: [PATCH 1/7] Backport some JEI features * Licensed under LGPL * Remove TMI style * Remove Load/Save inventory state * Reworked ItemPanel so it's no longer used statically * BookmarkPanel inherits from ItemPanel * Rework LayoutManager * Bookmarks - including loading & saving * Utility/Cheat buttons line up and wrap based on GUI size --- .gitignore | 8 +- COPYING | 674 ++++++++++++++++++ COPYING.LESSER | 165 +++++ LICENSE.txt | 10 + build/build.gradle | 9 + build/build.properties | 4 +- resources/assets/nei/lang/cs_CZ.lang | 5 +- resources/assets/nei/lang/de_DE.lang | 5 +- resources/assets/nei/lang/en_US.lang | 7 +- resources/assets/nei/lang/et_EE.lang | 5 +- resources/assets/nei/lang/fr_FR.lang | 5 +- resources/assets/nei/lang/it_IT.lang | 5 +- resources/assets/nei/lang/ko_KR.lang | 4 - resources/assets/nei/lang/pl_PL.lang | 6 +- resources/assets/nei/lang/pt_BR.lang | 6 +- resources/assets/nei/lang/ru_RU.lang | 6 +- resources/assets/nei/lang/sk_SK.lang | 6 +- resources/assets/nei/lang/tr_TR.lang | 6 +- resources/assets/nei/lang/zh_CN.lang | 6 +- resources/assets/nei/lang/zh_TW.lang | 6 +- src/codechicken/nei/BookmarkPanel.java | 137 ++++ src/codechicken/nei/Image.java | 10 +- src/codechicken/nei/ItemList.java | 16 +- src/codechicken/nei/ItemMobSpawner.java | 8 +- src/codechicken/nei/ItemPanel.java | 136 +++- src/codechicken/nei/ItemPanels.java | 6 + src/codechicken/nei/ItemQuantityField.java | 2 +- src/codechicken/nei/ItemSorter.java | 8 +- src/codechicken/nei/Label.java | 2 +- src/codechicken/nei/LayoutManager.java | 163 ++--- src/codechicken/nei/LayoutStyleDefault.java | 153 ---- src/codechicken/nei/LayoutStyleMinecraft.java | 134 +++- src/codechicken/nei/LayoutStyleTMIOld.java | 135 ---- src/codechicken/nei/NEIClientConfig.java | 167 +---- src/codechicken/nei/NEIClientUtils.java | 17 +- src/codechicken/nei/SaveLoadButton.java | 120 ---- src/codechicken/nei/SearchField.java | 37 +- src/codechicken/nei/SubsetWidget.java | 26 +- src/codechicken/nei/TextField.java | 132 ++-- src/codechicken/nei/VisiblityData.java | 9 +- src/codechicken/nei/api/API.java | 16 +- .../nei/config/GuiItemIconDumper.java | 14 +- src/codechicken/nei/config/GuiItemSorter.java | 4 +- .../nei/config/GuiNEIOptionList.java | 24 +- src/codechicken/nei/config/GuiOptionList.java | 15 +- .../nei/config/ItemPanelDumper.java | 8 +- src/codechicken/nei/config/OptionButton.java | 7 +- .../nei/config/OptionGamemodes.java | 8 +- .../nei/config/OptionStringSet.java | 10 +- .../nei/config/OptionTextField.java | 6 +- .../nei/config/OptionUtilities.java | 8 +- src/codechicken/nei/config/PatreonButton.java | 23 - src/codechicken/nei/recipe/GuiRecipe.java | 8 +- .../nei/recipe/RecipeItemInputHandler.java | 8 +- 54 files changed, 1605 insertions(+), 920 deletions(-) create mode 100644 COPYING create mode 100644 COPYING.LESSER create mode 100644 src/codechicken/nei/BookmarkPanel.java create mode 100644 src/codechicken/nei/ItemPanels.java delete mode 100644 src/codechicken/nei/LayoutStyleDefault.java delete mode 100644 src/codechicken/nei/LayoutStyleTMIOld.java delete mode 100644 src/codechicken/nei/SaveLoadButton.java delete mode 100644 src/codechicken/nei/config/PatreonButton.java diff --git a/.gitignore b/.gitignore index 05de45421..68123f687 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 000000000..19d1fa01f --- /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 000000000..0a041280b --- /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 bed16e88f..2bfb55030 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 c6132db6f..86e493e53 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 f272e0b9a..1f4beb2e1 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 298776dcd..0582d88b6 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 3b67e4047..1f9b78b6a 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 428da3a58..e0a0a7d8b 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 446d67438..78fddc640 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 776effb3c..b84c781cb 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 63302230c..85a8576f1 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 f1d4d543a..d66aba629 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 fafa832fe..93a4162e6 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 f694bb4e9..eb6cb8592 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 f879154d6..4918e0c36 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 825262439..fe119ecf3 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 0f2027c82..05dd4ef56 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 433d90030..484fd112c 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 0c8fe6084..3b016a752 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 000000000..2da7d7285 --- /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 5634a4f7a..4fb746a62 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 fac8434cd..4ffdba8bb 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 void execute() { 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 21d042922..289401f71 100644 --- a/src/codechicken/nei/ItemMobSpawner.java +++ b/src/codechicken/nei/ItemMobSpawner.java @@ -17,10 +17,8 @@ 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 static void loadSpawners(World world) { } } - 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 6943bcde0..00d13f4c1 100644 --- a/src/codechicken/nei/ItemPanel.java +++ b/src/codechicken/nei/ItemPanel.java @@ -14,19 +14,23 @@ 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 ItemPanelSlot(int index) { 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 ItemPanelSlot(int index) { 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 @@ private void calculatePage() { 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 void postDraw(int mousex, int mousey) { @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 000000000..ffecb678d --- /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 5d5d9d3f5..6ca23f694 100644 --- a/src/codechicken/nei/ItemQuantityField.java +++ b/src/codechicken/nei/ItemQuantityField.java @@ -7,7 +7,7 @@ public ItemQuantityField(String ident) { 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 53d24e1a8..cc4e82f2e 100644 --- a/src/codechicken/nei/ItemSorter.java +++ b/src/codechicken/nei/ItemSorter.java @@ -10,7 +10,10 @@ 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 String getTooltip() { 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 2ba5e6e48..fbff8de92 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 431f9209e..23577e7a2 100644 --- a/src/codechicken/nei/LayoutManager.java +++ b/src/codechicken/nei/LayoutManager.java @@ -2,8 +2,18 @@ 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.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 void onPreDraw(GuiContainer gui) { } } + 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 static void layout(GuiContainer gui) { } 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 String getRenderLabel() { return translate("inventory.options"); } }; - prev = new Button("Prev") - { - public boolean onButtonPress(boolean rightclick) { - if (!rightclick) { - LayoutManager.itemPanel.scroll(-1); - return true; - } - return false; - } - @Override - public String getRenderLabel() { - return translate("inventory.prev"); - } - }; - next = new Button("Next") + 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.next"); + return translate("bookmark.toggle"); } }; - pageLabel = new Label("(0/0)", true); more = new Button("+") { @Override @@ -350,43 +382,6 @@ public boolean onButtonPress(boolean rightclick) { }; 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 static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visib 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 static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visib } } + 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 static LayoutStyle getLayoutStyle(int id) { } 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 void tickKeyStates() { 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 7e553436b..000000000 --- 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 57d3a1522..c535b2b3e 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 String getName() { @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 void drawButton(Button b, int mousex, int mousey) { 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 @@ else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) ||//not a state butt 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 325990ebd..000000000 --- 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 5681657ae..ec6e512d6 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.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 boolean optionValid(int index) { 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 @@ private static void setDefaultKeyBindings() { 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 static void bootNEI(World world) { 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 boolean matches(String test) { 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 static boolean areDamageVariantsShown() { 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 static boolean canPerformAction(String name) { 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 df0a8301c..469a0ec93 100644 --- a/src/codechicken/nei/NEIClientUtils.java +++ b/src/codechicken/nei/NEIClientUtils.java @@ -22,9 +22,20 @@ import java.text.MessageFormat; import java.text.NumberFormat; -import java.util.*; - -import static codechicken.nei.NEIClientConfig.*; +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.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 5b589cd04..000000000 --- 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 e00049a0c..a86e2e607 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.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 static boolean searchInventories() { } @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 boolean handleClick(int mousex, int mousey, int button) { @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 7db14afa0..42f340563 100644 --- a/src/codechicken/nei/SubsetWidget.java +++ b/src/codechicken/nei/SubsetWidget.java @@ -18,9 +18,14 @@ 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 @@ protected void slotClicked(int slot, int button, int mx, int my, int count) { 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 @@ protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) { 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 @@ protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) { 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 ItemStack getStackMouseOver(int mx, int my) { @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 c1c32ed90..f5f9fb2c6 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 void onGuiClick(int mousex, int mousey) { @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 boolean handleKeyPress(int keyID, char keyChar) { 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); + } - return true; - } + if(handled) { + onTextChange(text()); + } + + 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 String filterText(String s) { } 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 f5753aa8e..5d0a23b58 100644 --- a/src/codechicken/nei/VisiblityData.java +++ b/src/codechicken/nei/VisiblityData.java @@ -3,11 +3,14 @@ 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 void translateDependancies() 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 6da0291cf..c1103af64 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 dae3ada57..8a0689cf7 100644 --- a/src/codechicken/nei/config/GuiItemIconDumper.java +++ b/src/codechicken/nei/config/GuiItemIconDumper.java @@ -2,7 +2,7 @@ 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.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 @@ private void drawItems() { 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 @@ private void exportItems() throws IOException { 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 56e7caafd..8e870fc9d 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 4bb6dcb0b..7828eba50 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 GuiNEIOptionList(GuiScreen parent, OptionList optionList, boolean world) @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 0425bb9c4..66b6cd58c 100644 --- a/src/codechicken/nei/config/GuiOptionList.java +++ b/src/codechicken/nei/config/GuiOptionList.java @@ -6,19 +6,21 @@ 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 OptionScrollSlot() { @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 822e52bcf..350742d70 100644 --- a/src/codechicken/nei/config/ItemPanelDumper.java +++ b/src/codechicken/nei/config/ItemPanelDumper.java @@ -2,7 +2,7 @@ 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 String[] header() { @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 @@ else if (getMode() == 1) 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 void dumpNBT(File file) throws IOException { 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 aba195940..385171170 100644 --- a/src/codechicken/nei/config/OptionButton.java +++ b/src/codechicken/nei/config/OptionButton.java @@ -4,10 +4,13 @@ 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 d4ffc3c67..0c189f644 100644 --- a/src/codechicken/nei/config/OptionGamemodes.java +++ b/src/codechicken/nei/config/OptionGamemodes.java @@ -18,8 +18,10 @@ public OptionGamemodes(String name) 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 bd4c97abf..03499f006 100644 --- a/src/codechicken/nei/config/OptionStringSet.java +++ b/src/codechicken/nei/config/OptionStringSet.java @@ -5,7 +5,11 @@ 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 void mouseClicked(int x, int y, int button) { 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 6bbef94ca..48538a8c4 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 7d309866c..a2004f627 100644 --- a/src/codechicken/nei/config/OptionUtilities.java +++ b/src/codechicken/nei/config/OptionUtilities.java @@ -44,8 +44,10 @@ public void drawIcons() 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 1b32c54bc..000000000 --- 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 e80a3a929..97a6059d9 100644 --- a/src/codechicken/nei/recipe/GuiRecipe.java +++ b/src/codechicken/nei/recipe/GuiRecipe.java @@ -2,8 +2,11 @@ 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.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 3dd3e740b..603b79455 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 boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) 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; } From f272e5942ebdb0c63934b591eff9ff03da93591b Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Dec 2019 14:41:56 -0800 Subject: [PATCH 2/7] Add JEI inspiration/backport attribution & license info --- LICENSE.txt | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 2bfb55030..455a58d05 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,16 +1,45 @@ GTNH Modifications: +Copyright (c) 2019 mitchej123 + GNU LESSER GENERAL PUBLIC LICENSE - See COPYING & COPYING.LESSER -Copyright (c) 2019 mitchej123 +----------------------------------------------------------------------------- + +Parts inspired/borrowed/backported from JEI under the MIT License: + + https://github.com/mezz/JustEnoughItems/tree/1.12 + + The MIT License (MIT) + + Copyright (c) 2014-2015 mezz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- Base NEI License: -The MIT License (MIT) + The MIT License (MIT) -Copyright (c) 2014 ChickenBones + Copyright (c) 2014 ChickenBones Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From e3462ac9c9e3f5b96e989f0f79f0b36faad4bb28 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Dec 2019 16:32:04 -0800 Subject: [PATCH 3/7] Fix AppleCore crash --- build/build.properties | 2 +- src/codechicken/nei/ItemPanel.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/build.properties b/build/build.properties index 1f4beb2e1..09668133c 100644 --- a/build/build.properties +++ b/build/build.properties @@ -2,4 +2,4 @@ mc_version=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=2.0.0-pre-3-GTNH +mod_version=2.0.0-pre-4-GTNH diff --git a/src/codechicken/nei/ItemPanel.java b/src/codechicken/nei/ItemPanel.java index 00d13f4c1..4c07680d8 100644 --- a/src/codechicken/nei/ItemPanel.java +++ b/src/codechicken/nei/ItemPanel.java @@ -30,8 +30,8 @@ public ArrayList getItems() { return items; } - public void updateItemList(ArrayList newItems) { - _items = newItems; + public static void updateItemList(ArrayList newItems) { + ItemPanels.itemPanel._items = newItems; } public class ItemPanelSlot From 05b5fa7baf4cfc06c60150e4b18991b009bbacb8 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Dec 2019 20:19:16 -0800 Subject: [PATCH 4/7] Intellij suggested changes --- build/build.properties | 2 +- resources/assets/nei/lang/ko_KR.lang | 1 - resources/assets/nei/lang/pl_PL.lang | 2 - resources/assets/nei/lang/ru_RU.lang | 1 - resources/assets/nei/lang/zh_TW.lang | 1 - src/codechicken/nei/Button.java | 2 +- src/codechicken/nei/ClientHandler.java | 10 +- src/codechicken/nei/ContainerCreativeInv.java | 2 +- .../nei/ContainerEnchantmentModifier.java | 14 +-- .../nei/ContainerPotionCreator.java | 8 +- src/codechicken/nei/ExtendedCreativeInv.java | 7 +- src/codechicken/nei/FastTransferManager.java | 25 +++-- .../nei/GuiEnchantmentModifier.java | 2 +- .../nei/GuiExtendedCreativeInv.java | 4 +- src/codechicken/nei/GuiNEIButton.java | 2 +- src/codechicken/nei/GuiPotionCreator.java | 6 +- src/codechicken/nei/HUDRenderer.java | 10 +- src/codechicken/nei/ItemList.java | 30 +++--- src/codechicken/nei/ItemMobSpawner.java | 4 +- src/codechicken/nei/ItemPanel.java | 2 +- src/codechicken/nei/ItemPanels.java | 4 +- src/codechicken/nei/ItemSorter.java | 98 +++++++------------ src/codechicken/nei/ItemStackMap.java | 45 ++++----- src/codechicken/nei/KeyManager.java | 4 +- src/codechicken/nei/Label.java | 4 +- src/codechicken/nei/LayoutManager.java | 8 +- src/codechicken/nei/NEIActions.java | 6 +- src/codechicken/nei/NEIChestGuiHandler.java | 5 +- src/codechicken/nei/NEIClientConfig.java | 10 +- src/codechicken/nei/NEIClientUtils.java | 4 +- src/codechicken/nei/NEIController.java | 12 ++- src/codechicken/nei/NEIModContainer.java | 25 ++--- src/codechicken/nei/NEISPH.java | 47 ++++----- src/codechicken/nei/NEIServerConfig.java | 29 +++--- src/codechicken/nei/NEIServerUtils.java | 14 ++- src/codechicken/nei/OffsetPositioner.java | 2 +- src/codechicken/nei/PlayerSave.java | 1 - src/codechicken/nei/PositionedStack.java | 4 +- src/codechicken/nei/SearchField.java | 6 +- src/codechicken/nei/SpawnerRenderer.java | 1 - src/codechicken/nei/SubsetWidget.java | 19 ++-- src/codechicken/nei/TextField.java | 5 +- src/codechicken/nei/ThreadOperationTimer.java | 2 +- src/codechicken/nei/WidgetZOrder.java | 2 +- src/codechicken/nei/WorldOverlayRenderer.java | 4 +- .../nei/api/DefaultOverlayRenderer.java | 4 +- src/codechicken/nei/api/GuiInfo.java | 4 +- src/codechicken/nei/api/ItemInfo.java | 88 +++++++---------- src/codechicken/nei/api/NEIInfo.java | 2 +- .../nei/api/TaggedInventoryArea.java | 6 +- src/codechicken/nei/asm/NEITransformer.java | 41 ++++++-- src/codechicken/nei/config/ArrayDumper.java | 2 +- src/codechicken/nei/config/ConfigSet.java | 5 +- .../nei/config/GuiHighlightTips.java | 7 +- .../nei/config/GuiItemIconDumper.java | 4 +- src/codechicken/nei/config/GuiItemSorter.java | 10 +- src/codechicken/nei/config/GuiOptionList.java | 4 +- src/codechicken/nei/config/GuiOptionPane.java | 7 +- .../nei/config/ItemPanelDumper.java | 4 +- src/codechicken/nei/config/OptionButton.java | 2 +- .../nei/config/OptionIntegerField.java | 4 +- src/codechicken/nei/config/OptionList.java | 4 +- .../nei/config/OptionStringSet.java | 19 ++-- .../nei/config/OptionTextField.java | 2 +- .../nei/config/RegistryDumper.java | 2 +- .../nei/guihook/GuiContainerManager.java | 27 ++--- .../nei/recipe/BrewingRecipeHandler.java | 34 ++----- .../nei/recipe/ContainerRecipe.java | 9 +- .../nei/recipe/DefaultOverlayHandler.java | 44 +++++---- .../nei/recipe/FireworkRecipeHandler.java | 21 ++-- .../nei/recipe/FuelRecipeHandler.java | 4 +- .../nei/recipe/FurnaceRecipeHandler.java | 25 ++--- .../nei/recipe/GuiCraftingRecipe.java | 4 +- src/codechicken/nei/recipe/GuiRecipe.java | 2 +- .../nei/recipe/GuiUsageRecipe.java | 4 +- .../nei/recipe/ProfilerRecipeHandler.java | 21 ++-- src/codechicken/nei/recipe/RecipeInfo.java | 16 +-- .../nei/recipe/ShapedRecipeHandler.java | 4 +- .../nei/recipe/ShapelessRecipeHandler.java | 2 +- .../nei/recipe/TemplateRecipeHandler.java | 32 +++--- 80 files changed, 479 insertions(+), 487 deletions(-) diff --git a/build/build.properties b/build/build.properties index 09668133c..4e1973dbd 100644 --- a/build/build.properties +++ b/build/build.properties @@ -2,4 +2,4 @@ mc_version=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=2.0.0-pre-4-GTNH +mod_version=2.0.0-pre-5-GTNH diff --git a/resources/assets/nei/lang/ko_KR.lang b/resources/assets/nei/lang/ko_KR.lang index d66aba629..b1b0fec7b 100644 --- a/resources/assets/nei/lang/ko_KR.lang +++ b/resources/assets/nei/lang/ko_KR.lang @@ -10,7 +10,6 @@ nei.inventory.options=옵션 nei.inventory.prev=이전 nei.inventory.next=다음 nei.inventory.item_subsets=아이템 하위집합 -nei.inventory.delete.all=현재의 화면에 있는 모든 항목을 삭제 nei.inventory.delete.one=%s 삭제 nei.inventory.delete.all=%s 모두삭제 nei.inventory.delete.enable=삭제모드 활성화 diff --git a/resources/assets/nei/lang/pl_PL.lang b/resources/assets/nei/lang/pl_PL.lang index 93a4162e6..419036425 100644 --- a/resources/assets/nei/lang/pl_PL.lang +++ b/resources/assets/nei/lang/pl_PL.lang @@ -64,7 +64,6 @@ nei.options.keys.gui.back=Poprzednia recepta nei.options.keys.gui.prev=Poprzednia strona nei.options.keys.gui.next=Następna strona nei.options.keys.gui.hide=Przełącz widzialność NEI -nei.options.keys.gui.search=Focus Search Bar nei.options.keys.gui.search=Ustaw ostrość na pasek wyszukiwania nei.options.keys.world=Świat nei.options.keys.world.chunkoverlay=Nakładka granic chunków @@ -99,7 +98,6 @@ nei.options.inventory.searchmode.0=Prosty nei.options.inventory.searchmode.1=Rozszerzony nei.options.inventory.searchmode.2=Wyrażenia regularne nei.options.inventory.utilities=Narzędzia -nei.options.inventory.utilities.tip=Select features for utility mode nei.options.inventory.utilities.tip=Wybierz cechy trybu użytkowego nei.options.inventory.utilities.time=Czas nei.options.inventory.utilities.rain=Deszcz diff --git a/resources/assets/nei/lang/ru_RU.lang b/resources/assets/nei/lang/ru_RU.lang index 4918e0c36..300bfa8b7 100644 --- a/resources/assets/nei/lang/ru_RU.lang +++ b/resources/assets/nei/lang/ru_RU.lang @@ -14,7 +14,6 @@ nei.inventory.options=Опции nei.inventory.prev=Предыдущая nei.inventory.next=Следующая nei.inventory.item_subsets=Подмножества предметов -nei.inventory.delete.all=УДАЛИТЬ ВСЕ ПРЕДМЕТЫ из текущего инвентаря nei.inventory.delete.one=Удалить %s nei.inventory.delete.all=Удалить ВСЕ %s nei.inventory.delete.enable=Режим удаления diff --git a/resources/assets/nei/lang/zh_TW.lang b/resources/assets/nei/lang/zh_TW.lang index 3b016a752..5d86fdf2d 100644 --- a/resources/assets/nei/lang/zh_TW.lang +++ b/resources/assets/nei/lang/zh_TW.lang @@ -12,7 +12,6 @@ nei.inventory.next=下一頁 nei.inventory.item_subsets=物品分類表 nei.inventory.delete.all=刪除當前物品欄內所有物品 nei.inventory.delete.one=刪除 %s -nei.inventory.delete.all=清空物品欄 nei.inventory.delete.enable=開啟刪除模式設定 nei.inventory.delete.1=開啟刪除模式 nei.inventory.delete.0=關閉刪除模式 diff --git a/src/codechicken/nei/Button.java b/src/codechicken/nei/Button.java index 6a57e46f8..13e4dfb0b 100644 --- a/src/codechicken/nei/Button.java +++ b/src/codechicken/nei/Button.java @@ -56,7 +56,7 @@ public String getRenderLabel() { return label; } - public String label; + public final String label; public Image icon; /** diff --git a/src/codechicken/nei/ClientHandler.java b/src/codechicken/nei/ClientHandler.java index 5428aa8ae..d2e27c312 100644 --- a/src/codechicken/nei/ClientHandler.java +++ b/src/codechicken/nei/ClientHandler.java @@ -12,7 +12,11 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.*; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSelectWorld; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -28,14 +32,14 @@ public class ClientHandler { private static ClientHandler instance; - private ArrayList SMPmagneticItems = new ArrayList(); + private ArrayList SMPmagneticItems = new ArrayList<>(); private World lastworld; private GuiScreen lastGui; public void addSMPMagneticItem(int i, World world) { WorldClient cworld = (WorldClient) world; Entity e = cworld.getEntityByID(i); - if (e == null || !(e instanceof EntityItem)) { + if (!(e instanceof EntityItem)) { return; } SMPmagneticItems.add((EntityItem) e); diff --git a/src/codechicken/nei/ContainerCreativeInv.java b/src/codechicken/nei/ContainerCreativeInv.java index e528d7420..ab2c2b873 100644 --- a/src/codechicken/nei/ContainerCreativeInv.java +++ b/src/codechicken/nei/ContainerCreativeInv.java @@ -15,7 +15,7 @@ public class ContainerCreativeInv extends Container { private class SlotArmor extends Slot { - int armorType; + final int armorType; public SlotArmor(IInventory inv, int x, int y, int slot, int armor) { super(inv, x, y, slot); diff --git a/src/codechicken/nei/ContainerEnchantmentModifier.java b/src/codechicken/nei/ContainerEnchantmentModifier.java index 1e1696285..693def941 100644 --- a/src/codechicken/nei/ContainerEnchantmentModifier.java +++ b/src/codechicken/nei/ContainerEnchantmentModifier.java @@ -29,12 +29,12 @@ public EnchantmentHash(Enchantment e, int i, int l) { level = l; } - Enchantment enchantment; + final Enchantment enchantment; int state; - int level; + final int level; } - public ArrayList slotEnchantment = new ArrayList(); + public final ArrayList slotEnchantment = new ArrayList<>(); int level = 5; public int scrollclicky = -1; @@ -60,11 +60,7 @@ public int getScrollBarHeight() { int sbarh = (int) ((height / (float) getContentHeight()) * height); if (sbarh > height) { return height; - } else if (sbarh < height / 15) { - return height / 15; - } else { - return sbarh; - } + } else return Math.max(sbarh, height / 15); } public int getScrollBarWidth() { @@ -237,7 +233,7 @@ public void updateEnchantmentOptions(boolean validate) { public void drawSlots(GuiEnchantmentModifier gui) { for (int slot = 0; slot < 3; slot++) { - int shade = 0; + int shade; String text = ""; int containerslot = slot + getScrolledSlots(); diff --git a/src/codechicken/nei/ContainerPotionCreator.java b/src/codechicken/nei/ContainerPotionCreator.java index d89f82cb1..a1fb9cc90 100644 --- a/src/codechicken/nei/ContainerPotionCreator.java +++ b/src/codechicken/nei/ContainerPotionCreator.java @@ -1,9 +1,9 @@ package codechicken.nei; import codechicken.lib.inventory.ContainerExtended; -import codechicken.lib.inventory.SlotHandleClicks; import codechicken.lib.inventory.InventoryNBT; import codechicken.lib.inventory.InventoryUtils; +import codechicken.lib.inventory.SlotHandleClicks; import codechicken.lib.packet.PacketCustom; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -86,9 +86,9 @@ public void markDirty() { } } - InventoryPlayer playerInv; - InventoryBasic potionInv; - IInventory potionStoreInv; + final InventoryPlayer playerInv; + final InventoryBasic potionInv; + final IInventory potionStoreInv; public ContainerPotionCreator(InventoryPlayer inventoryPlayer, IInventory potionStoreInv) { playerInv = inventoryPlayer; diff --git a/src/codechicken/nei/ExtendedCreativeInv.java b/src/codechicken/nei/ExtendedCreativeInv.java index 1a992b277..62ce54bd1 100644 --- a/src/codechicken/nei/ExtendedCreativeInv.java +++ b/src/codechicken/nei/ExtendedCreativeInv.java @@ -7,8 +7,8 @@ public class ExtendedCreativeInv implements IInventory { - PlayerSave playerSave; - Side side; + final PlayerSave playerSave; + final Side side; public ExtendedCreativeInv(PlayerSave playerSave, Side side) { this.playerSave = playerSave; @@ -33,10 +33,9 @@ public ItemStack decrStackSize(int slot, int size) { if (item != null) { if (item.stackSize <= size) { - ItemStack itemstack = item; setInventorySlotContents(slot, null); markDirty(); - return itemstack; + return item; } ItemStack itemstack1 = item.splitStack(size); if (item.stackSize == 0) { diff --git a/src/codechicken/nei/FastTransferManager.java b/src/codechicken/nei/FastTransferManager.java index a429cb3f4..d33650947 100644 --- a/src/codechicken/nei/FastTransferManager.java +++ b/src/codechicken/nei/FastTransferManager.java @@ -6,9 +6,14 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.*; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; -import static codechicken.nei.NEIServerUtils.*; +import static codechicken.nei.NEIServerUtils.areStacksIdentical; +import static codechicken.nei.NEIServerUtils.areStacksSameType; +import static codechicken.nei.NEIServerUtils.copyStack; public class FastTransferManager { @@ -17,7 +22,7 @@ public class FastTransferManager */ public static class SlotPositionComparator implements Comparator { - Container container; + final Container container; public SlotPositionComparator(Container c) { container = c; @@ -34,8 +39,8 @@ public int compare(Integer arg0, Integer arg1) { } } - public LinkedList> slotZones = new LinkedList>(); - public HashMap slotZoneMap = new HashMap(); + public LinkedList> slotZones = new LinkedList<>(); + public HashMap slotZoneMap = new HashMap<>(); private void generateSlotMap(Container container, ItemStack stack) { stack = stack.copy(); @@ -45,11 +50,11 @@ private void generateSlotMap(Container container, ItemStack stack) { if (slotZoneMap.containsKey(slotNo) || !container.getSlot(slotNo).isItemValid(stack)) continue; - HashSet connectedSlots = new HashSet(); + HashSet connectedSlots = new HashSet<>(); findConnectedSlots(container, slotNo, connectedSlots); - LinkedList zoneSlots = new LinkedList(connectedSlots); - Collections.sort(zoneSlots, new SlotPositionComparator(container)); + LinkedList zoneSlots = new LinkedList<>(connectedSlots); + zoneSlots.sort(new SlotPositionComparator(container)); slotZones.add(zoneSlots); for (int i : zoneSlots) { @@ -77,7 +82,7 @@ private void findConnectedSlots(Container container, int slotNo, HashSet saveContainer(Container container) { - LinkedList stacks = new LinkedList(); + LinkedList stacks = new LinkedList<>(); for (int i = 0; i < container.inventorySlots.size(); i++) stacks.add(copyStack(container.getSlot(i).getStack())); diff --git a/src/codechicken/nei/GuiEnchantmentModifier.java b/src/codechicken/nei/GuiEnchantmentModifier.java index d2d5740ac..bc2571ff7 100644 --- a/src/codechicken/nei/GuiEnchantmentModifier.java +++ b/src/codechicken/nei/GuiEnchantmentModifier.java @@ -12,7 +12,7 @@ public class GuiEnchantmentModifier extends GuiContainer { - ContainerEnchantmentModifier container; + final ContainerEnchantmentModifier container; public GuiEnchantmentModifier(InventoryPlayer inventoryplayer, World world, int i, int j, int k) { super(new ContainerEnchantmentModifier(inventoryplayer, world, i, j, k)); diff --git a/src/codechicken/nei/GuiExtendedCreativeInv.java b/src/codechicken/nei/GuiExtendedCreativeInv.java index 5c6586028..b22f789c8 100644 --- a/src/codechicken/nei/GuiExtendedCreativeInv.java +++ b/src/codechicken/nei/GuiExtendedCreativeInv.java @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class GuiExtendedCreativeInv extends GuiContainer implements INEIGuiHandler @@ -41,7 +41,7 @@ public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { @Override public List getInventoryAreas(GuiContainer gui) { - return Arrays.asList(new TaggedInventoryArea("ExtendedCreativeInv", 0, 54, inventorySlots)); + return Collections.singletonList(new TaggedInventoryArea("ExtendedCreativeInv", 0, 54, inventorySlots)); } @Override diff --git a/src/codechicken/nei/GuiNEIButton.java b/src/codechicken/nei/GuiNEIButton.java index c63fa357c..fc3bca19d 100644 --- a/src/codechicken/nei/GuiNEIButton.java +++ b/src/codechicken/nei/GuiNEIButton.java @@ -8,7 +8,7 @@ public class GuiNEIButton extends GuiButton { - protected static ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png"); + protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png"); public GuiNEIButton(int i, int j, int k, int l, int i1, String s) { diff --git a/src/codechicken/nei/GuiPotionCreator.java b/src/codechicken/nei/GuiPotionCreator.java index f3d574d4f..ed1212b84 100644 --- a/src/codechicken/nei/GuiPotionCreator.java +++ b/src/codechicken/nei/GuiPotionCreator.java @@ -14,7 +14,7 @@ import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; -import java.awt.*; +import java.awt.Dimension; import java.util.ArrayList; import static codechicken.nei.NEIClientUtils.translate; @@ -25,7 +25,7 @@ public class GuiSlotPotionEffects extends GuiScrollSlot { public int selectedslot = -1; public boolean enabled = true; - private ArrayList validPotions = new ArrayList(); + private final ArrayList validPotions = new ArrayList<>(); public GuiSlotPotionEffects(int x, int y) { super(x, y, 108, 76); @@ -256,7 +256,7 @@ public int getDurationTicks() { GuiCCButton ampUp; GuiSlotPotionEffects slotPotionEffects; GuiDurationField durationField; - ContainerPotionCreator container; + final ContainerPotionCreator container; public GuiPotionCreator(InventoryPlayer inventoryplayer) { super(new ContainerPotionCreator(inventoryplayer, new ContainerPotionCreator.InventoryPotionStore()), 176, 208); diff --git a/src/codechicken/nei/HUDRenderer.java b/src/codechicken/nei/HUDRenderer.java index 1680899b6..4171c89b1 100644 --- a/src/codechicken/nei/HUDRenderer.java +++ b/src/codechicken/nei/HUDRenderer.java @@ -12,13 +12,15 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.awt.*; +import java.awt.Dimension; +import java.awt.Point; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; -import static codechicken.lib.gui.GuiDraw.*; +import static codechicken.lib.gui.GuiDraw.displaySize; +import static codechicken.lib.gui.GuiDraw.drawString; +import static codechicken.lib.gui.GuiDraw.drawTooltipBox; +import static codechicken.lib.gui.GuiDraw.getStringWidth; public class HUDRenderer implements IKeyStateTracker { diff --git a/src/codechicken/nei/ItemList.java b/src/codechicken/nei/ItemList.java index 4ffdba8bb..6f964cb08 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. */ @@ -30,11 +30,11 @@ public class ItemList /** * Updates to this should be synchronised on this */ - public static final List itemFilterers = new LinkedList(); - public static final List loadCallbacks = new LinkedList(); + public static final List itemFilterers = new LinkedList<>(); + public static final List loadCallbacks = new LinkedList<>(); - private static HashSet erroredItems = new HashSet(); - private static HashSet stackTraces = new HashSet(); + private static final HashSet erroredItems = new HashSet<>(); + private static final HashSet stackTraces = new HashSet<>(); public static class EverythingItemFilter implements ItemFilter { @@ -68,14 +68,14 @@ public boolean matches(ItemStack item) { public static class AllMultiItemFilter implements ItemFilter { - public List filters = new LinkedList(); + public List filters; public AllMultiItemFilter(List filters) { this.filters = filters; } public AllMultiItemFilter() { - this(new LinkedList()); + this(new LinkedList<>()); } @Override @@ -93,14 +93,14 @@ public boolean matches(ItemStack item) { public static class AnyMultiItemFilter implements ItemFilter { - public List filters = new LinkedList(); + public List filters; public AnyMultiItemFilter(List filters) { this.filters = filters; } public AnyMultiItemFilter() { - this(new LinkedList()); + this(new LinkedList<>()); } @Override @@ -147,7 +147,7 @@ public static ItemFilter getItemListFilter() { } public static List getItemFilters() { - LinkedList filters = new LinkedList(); + LinkedList filters = new LinkedList<>(); synchronized (itemFilterers) { for(ItemFilterProvider p : itemFilterers) filters.add(p.getFilter()); @@ -158,7 +158,7 @@ public static List getItemFilters() { public static final RestartableTask loadItems = new RestartableTask("NEI Item Loading") { private void damageSearch(Item item, List permutations) { - HashSet damageIconSet = new HashSet(); + HashSet damageIconSet = new HashSet<>(); for (int damage = 0; damage < 16; damage++) try { ItemStack itemstack = new ItemStack(item, 1, damage); @@ -182,8 +182,8 @@ private void damageSearch(Item item, List permutations) { public void execute() { ThreadOperationTimer timer = getTimer(500); - LinkedList items = new LinkedList(); - LinkedList permutations = new LinkedList(); + LinkedList items = new LinkedList<>(); + LinkedList permutations = new LinkedList<>(); ListMultimap itemMap = ArrayListMultimap.create(); timer.setLimit(500); @@ -231,7 +231,7 @@ public void execute() { { @Override public void execute() { - ArrayList filtered = new ArrayList(); + ArrayList filtered = new ArrayList<>(); ItemFilter filter = getItemListFilter(); items.parallelStream().forEach(item -> { @@ -247,7 +247,7 @@ public void execute() { if(interrupted()) return; ItemSorter.sort(filtered); if(interrupted()) return; - ItemPanels.itemPanel.updateItemList(filtered); + ItemPanel.updateItemList(filtered); } }; diff --git a/src/codechicken/nei/ItemMobSpawner.java b/src/codechicken/nei/ItemMobSpawner.java index 289401f71..43ccf4061 100644 --- a/src/codechicken/nei/ItemMobSpawner.java +++ b/src/codechicken/nei/ItemMobSpawner.java @@ -33,8 +33,8 @@ public ItemMobSpawner() { hasSubtypes = true; MinecraftForgeClient.registerItemRenderer(this, new SpawnerRenderer()); - entityHashMap = new HashMap(); - IDtoNameMap = new HashMap(); + entityHashMap = new HashMap<>(); + IDtoNameMap = new HashMap<>(); } /** diff --git a/src/codechicken/nei/ItemPanel.java b/src/codechicken/nei/ItemPanel.java index 4c07680d8..d4d2a7eb4 100644 --- a/src/codechicken/nei/ItemPanel.java +++ b/src/codechicken/nei/ItemPanel.java @@ -20,7 +20,7 @@ public class ItemPanel extends Widget { /** * Should not be externally modified, use updateItemList */ - public ArrayList items = new ArrayList(); + public ArrayList items = new ArrayList<>(); /** * Swapped into visible items on update */ diff --git a/src/codechicken/nei/ItemPanels.java b/src/codechicken/nei/ItemPanels.java index ffecb678d..2eb3b5d2d 100644 --- a/src/codechicken/nei/ItemPanels.java +++ b/src/codechicken/nei/ItemPanels.java @@ -1,6 +1,6 @@ package codechicken.nei; public class ItemPanels { - public static ItemPanel itemPanel = new ItemPanel(); - public static BookmarkPanel bookmarkPanel = new BookmarkPanel(); + public static final ItemPanel itemPanel = new ItemPanel(); + public static final BookmarkPanel bookmarkPanel = new BookmarkPanel(); } diff --git a/src/codechicken/nei/ItemSorter.java b/src/codechicken/nei/ItemSorter.java index cc4e82f2e..fd8578b7a 100644 --- a/src/codechicken/nei/ItemSorter.java +++ b/src/codechicken/nei/ItemSorter.java @@ -19,8 +19,8 @@ public class ItemSorter implements Comparator, ItemsLoadedCallback { public static class SortEntry { - public String name; - public Comparator comparator; + public final String name; + public final Comparator comparator; public SortEntry(String name, Comparator comparator) { this.name = name; @@ -38,8 +38,8 @@ public String getTooltip() { } } - public static ArrayList entries = new ArrayList(); - public static ArrayList list = new ArrayList(); + public static final ArrayList entries = new ArrayList<>(); + public static ArrayList list = new ArrayList<>(); public static final ItemSorter instance = new ItemSorter(); //optimisations @@ -65,7 +65,7 @@ public int compare(ItemStack o1, ItemStack o2) { @Override public void itemsLoaded() { - HashMap newMap = new HashMap(); + HashMap newMap = new HashMap<>(); int i = 0; for(ItemStack stack : ItemList.items) newMap.put(stack, i++); @@ -81,76 +81,52 @@ public static SortEntry find(String name) { } public static int compareInt(int a, int b) { - return a == b ? 0 : a < b ? -1 : 1; + return Integer.compare(a, b); } public static void add(String name, Comparator comparator) { SortEntry e = new SortEntry(name, comparator); entries.add(e); - ArrayList nlist = new ArrayList(list); + ArrayList nlist = new ArrayList<>(list); nlist.add(e); list = nlist;//concurrency } public static void initConfig(ConfigTagParent tag) { //minecraft, mod, id, default, meta, name - API.addSortOption("nei.itemsort.minecraft", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - boolean m1 = "minecraft".equals(ItemInfo.itemOwners.get(o1.getItem())); - boolean m2 = "minecraft".equals(ItemInfo.itemOwners.get(o2.getItem())); - return m1 == m2 ? 0 : m1 ? -1 : 1; - } + API.addSortOption("nei.itemsort.minecraft", (o1, o2) -> { + boolean m1 = "minecraft".equals(ItemInfo.itemOwners.get(o1.getItem())); + boolean m2 = "minecraft".equals(ItemInfo.itemOwners.get(o2.getItem())); + return m1 == m2 ? 0 : m1 ? -1 : 1; }); - API.addSortOption("nei.itemsort.mod", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - String mod1 = ItemInfo.itemOwners.get(o1.getItem()); - String mod2 = ItemInfo.itemOwners.get(o2.getItem()); - if(mod1 == null) return mod2 == null ? 0 : 1; - if(mod2 == null) return -1; - return mod1.compareTo(mod2); - } + API.addSortOption("nei.itemsort.mod", (o1, o2) -> { + String mod1 = ItemInfo.itemOwners.get(o1.getItem()); + String mod2 = ItemInfo.itemOwners.get(o2.getItem()); + if(mod1 == null) return mod2 == null ? 0 : 1; + if(mod2 == null) return -1; + return mod1.compareTo(mod2); }); - API.addSortOption("nei.itemsort.id", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - int id1 = Item.getIdFromItem(o1.getItem()); - int id2 = Item.getIdFromItem(o2.getItem()); - return compareInt(id1, id2); - } + API.addSortOption("nei.itemsort.id", (o1, o2) -> { + int id1 = Item.getIdFromItem(o1.getItem()); + int id2 = Item.getIdFromItem(o2.getItem()); + return compareInt(id1, id2); }); - API.addSortOption("nei.itemsort.default", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - Integer order1 = instance.ordering.get(o1); - Integer order2 = instance.ordering.get(o2); - if(order1 == null) return order2 == null ? 0 : 1; - if(order2 == null) return -1; - return compareInt(order1, order2); - } + API.addSortOption("nei.itemsort.default", (o1, o2) -> { + Integer order1 = instance.ordering.get(o1); + Integer order2 = instance.ordering.get(o2); + if(order1 == null) return order2 == null ? 0 : 1; + if(order2 == null) return -1; + return compareInt(order1, order2); }); - API.addSortOption("nei.itemsort.damage", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - int id1 = o1.getItemDamage(); - int id2 = o2.getItemDamage(); - return compareInt(id1, id2); - } + API.addSortOption("nei.itemsort.damage", (o1, o2) -> { + int id1 = o1.getItemDamage(); + int id2 = o2.getItemDamage(); + return compareInt(id1, id2); }); - API.addSortOption("nei.itemsort.name", new Comparator() - { - @Override - public int compare(ItemStack o1, ItemStack o2) { - String name1 = ItemInfo.getSearchName(o1); - String name2 = ItemInfo.getSearchName(o2); - return name1.compareTo(name2); - } + API.addSortOption("nei.itemsort.name", (o1, o2) -> { + String name1 = ItemInfo.getSearchName(o1); + String name2 = ItemInfo.getSearchName(o2); + return name1.compareTo(name2); }); tag.getTag("inventory.itemsort").setDefaultValue(getSaveString(list)); API.addOption(new OptionOpenGui("inventory.itemsort", GuiItemSorter.class) { @@ -175,9 +151,9 @@ public static String getSaveString(List list) { public static ArrayList fromSaveString(String s) { if(s == null) - return new ArrayList(entries); + return new ArrayList<>(entries); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for(String s2 : s.split(",")) { SortEntry e = find(s2.trim()); if(e != null) diff --git a/src/codechicken/nei/ItemStackMap.java b/src/codechicken/nei/ItemStackMap.java index 198ad1ce2..9636c7f83 100644 --- a/src/codechicken/nei/ItemStackMap.java +++ b/src/codechicken/nei/ItemStackMap.java @@ -1,6 +1,6 @@ package codechicken.nei; -import com.google.common.base.*; +import com.google.common.base.Objects; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,8 +21,8 @@ public class ItemStackMap { public static class StackMetaKey { - public int damage; - public NBTTagCompound tag; + public final int damage; + public final NBTTagCompound tag; public StackMetaKey(int damage, NBTTagCompound tag) { this.damage = damage; @@ -47,8 +47,8 @@ public boolean equals(Object o) { public static class Entry { - public ItemStack key; - public T value; + public final ItemStack key; + public final T value; public Entry(ItemStack key, T value) { this.key = key; @@ -70,11 +70,11 @@ public T get(ItemStack key) { return wildcard; if (damageMap != null) { - T ret = damageMap.get(actualDamage(key)); + final T ret = damageMap.get(actualDamage(key)); if (ret != null) return ret; } if (tagMap != null) { - T ret = tagMap.get(key.stackTagCompound); + final T ret = tagMap.get(key.stackTagCompound); if (ret != null) return ret; } if (metaMap != null) @@ -87,13 +87,13 @@ public T put(ItemStack key, T value) { try { switch (getKeyType(actualDamage(key), key.stackTagCompound)) { case 0: - if (metaMap == null) metaMap = new HashMap(); + if (metaMap == null) metaMap = new HashMap<>(); return metaMap.put(new StackMetaKey(key), value); case 1: - if (tagMap == null) tagMap = new HashMap(); + if (tagMap == null) tagMap = new HashMap<>(); return tagMap.put(key.stackTagCompound, value); case 2: - if (damageMap == null) damageMap = new HashMap(); + if (damageMap == null) damageMap = new HashMap<>(); return damageMap.put(actualDamage(key), value); case 3: T ret = wildcard; @@ -167,16 +167,16 @@ public void addValues(List list) { public void addEntries(Item item, List> list) { if (wildcard != null) - list.add(new Entry(newItemStack(item, 1, WILDCARD_VALUE, WILDCARD_TAG), wildcard)); + list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, WILDCARD_TAG), wildcard)); if (damageMap != null) for (Map.Entry entry : damageMap.entrySet()) - list.add(new Entry(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue())); + list.add(new Entry<>(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue())); if (tagMap != null) for (Map.Entry entry : tagMap.entrySet()) - list.add(new Entry(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue())); + list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue())); if (metaMap != null) for (Map.Entry entry : metaMap.entrySet()) - list.add(new Entry(newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue())); + list.add(new Entry<>(newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue())); } } @@ -199,21 +199,22 @@ public static boolean isWildcard(NBTTagCompound tag) { return tag != null && tag.getBoolean("*"); } - public static NBTTagCompound WILDCARD_TAG; + public static final NBTTagCompound WILDCARD_TAG; static { WILDCARD_TAG = new NBTTagCompound(); WILDCARD_TAG.setBoolean("*", true); } - private HashMap itemMap = new HashMap(); + private final HashMap itemMap = new HashMap<>(); private int size; public T get(ItemStack key) { - if (key == null || key.getItem() == null) - return null; + if (key == null) return null; + final Item item = key.getItem(); + if (item == null) return null; - DetailMap map = itemMap.get(key.getItem()); + final DetailMap map = itemMap.get(item); return map == null ? null : map.get(key); } @@ -240,21 +241,21 @@ public T remove(ItemStack key) { } public List keys() { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); for (Map.Entry entry : itemMap.entrySet()) entry.getValue().addKeys(entry.getKey(), list); return list; } public List values() { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); for (DetailMap map : itemMap.values()) map.addValues(list); return list; } public List> entries() { - LinkedList> list = new LinkedList>(); + LinkedList> list = new LinkedList<>(); for (Map.Entry entry : itemMap.entrySet()) entry.getValue().addEntries(entry.getKey(), list); return list; diff --git a/src/codechicken/nei/KeyManager.java b/src/codechicken/nei/KeyManager.java index 9e39fea6f..1d43fa523 100644 --- a/src/codechicken/nei/KeyManager.java +++ b/src/codechicken/nei/KeyManager.java @@ -23,8 +23,8 @@ public static class KeyState public boolean up; } - public static HashMap keyStates = new HashMap(); - public static LinkedList trackers = new LinkedList(); + public static HashMap keyStates = new HashMap<>(); + public static LinkedList trackers = new LinkedList<>(); public static void tickKeyStates() { diff --git a/src/codechicken/nei/Label.java b/src/codechicken/nei/Label.java index fbff8de92..72aae7c99 100644 --- a/src/codechicken/nei/Label.java +++ b/src/codechicken/nei/Label.java @@ -5,8 +5,8 @@ public class Label extends Widget { - boolean centered; - int colour; + final boolean centered; + final int colour; 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 23577e7a2..f1562ac0c 100644 --- a/src/codechicken/nei/LayoutManager.java +++ b/src/codechicken/nei/LayoutManager.java @@ -97,7 +97,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH public static IRecipeOverlayRenderer overlayRenderer; - public static HashMap layoutStyles = new HashMap(); + public static HashMap layoutStyles = new HashMap<>(); public static boolean ftbUtilsLoaded = false; @@ -588,8 +588,8 @@ public boolean checkCreativeInv(GuiContainer gui) { } public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visiblity) { - drawWidgets = new TreeSet(new WidgetZOrder(false)); - controlWidgets = new TreeSet(new WidgetZOrder(true)); + drawWidgets = new TreeSet<>(new WidgetZOrder(false)); + controlWidgets = new TreeSet<>(new WidgetZOrder(true)); if (!visiblity.showNEI) return; @@ -709,7 +709,7 @@ public void renderSlotUnderlay(GuiContainer gui, Slot slot) { @Override public void renderSlotOverlay(GuiContainer window, Slot slot) { ItemStack item = slot.getStack(); - if (world.nbt.getBoolean("searchinventories") && (item == null ? !getSearchExpression().equals("") : !ItemList.itemMatches(item))) { + if (world.nbt.getBoolean("searchinventories") && (item == null ? !getSearchExpression().equals("") : !ItemList.getItemListFilter().matches(item))) { GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(0, 0, 150); drawRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0x80000000); diff --git a/src/codechicken/nei/NEIActions.java b/src/codechicken/nei/NEIActions.java index a1f30825f..ac4b92417 100644 --- a/src/codechicken/nei/NEIActions.java +++ b/src/codechicken/nei/NEIActions.java @@ -9,8 +9,8 @@ public class NEIActions { public static final int protocol = 0; - public static HashMap nameActionMap = new HashMap(); - public static HashSet canDisable = new HashSet(); + public static HashMap nameActionMap = new HashMap<>(); + public static HashSet canDisable = new HashSet<>(); public static void addAction(String name, String base, boolean smpreq) { @@ -85,7 +85,7 @@ public NEIActions(String name, String base, boolean smpreq) public static List baseActions() { - List list = new LinkedList(); + List list = new LinkedList<>(); for(NEIActions a : nameActionMap.values()) if(a.base.equals(a.name)) list.add(a.name); diff --git a/src/codechicken/nei/NEIChestGuiHandler.java b/src/codechicken/nei/NEIChestGuiHandler.java index 98d30eff8..4a6b9c7b7 100644 --- a/src/codechicken/nei/NEIChestGuiHandler.java +++ b/src/codechicken/nei/NEIChestGuiHandler.java @@ -7,7 +7,6 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.item.ItemStack; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -19,11 +18,11 @@ public int chestSize(GuiContainer gui) { @Override public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { - return gui instanceof GuiChest ? NEIServerUtils.getRange(0, chestSize(gui)) : Collections.emptyList(); + return gui instanceof GuiChest ? NEIServerUtils.getRange(0, chestSize(gui)) : Collections.emptyList(); } @Override public List getInventoryAreas(GuiContainer gui) { - return gui instanceof GuiChest ? Arrays.asList(new TaggedInventoryArea("Chest", 0, chestSize(gui), gui.inventorySlots)) : null; + return gui instanceof GuiChest ? Collections.singletonList(new TaggedInventoryArea("Chest", 0, chestSize(gui), gui.inventorySlots)) : null; } } diff --git a/src/codechicken/nei/NEIClientConfig.java b/src/codechicken/nei/NEIClientConfig.java index ec6e512d6..44f04db63 100644 --- a/src/codechicken/nei/NEIClientConfig.java +++ b/src/codechicken/nei/NEIClientConfig.java @@ -50,14 +50,14 @@ 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 final File bookmarkFile = new File(configDir, "bookmarks.ini"); public static ItemStack[] creativeInv; public static boolean hasSMPCounterpart; - public static HashSet permissableActions = new HashSet(); - public static HashSet disabledActions = new HashSet(); - public static HashSet enabledActions = new HashSet(); + public static HashSet permissableActions = new HashSet<>(); + public static HashSet disabledActions = new HashSet<>(); + public static HashSet enabledActions = new HashSet<>(); public static ItemStackSet bannedBlocks = new ItemStackSet(); @@ -417,7 +417,7 @@ public static void reloadSaves() { logger.error("Error loading saves", e); return; } - HashSet saveFileNames = new HashSet(); + HashSet saveFileNames = new HashSet<>(); for (SaveFormatComparator save : saves) saveFileNames.add(save.getFileName()); diff --git a/src/codechicken/nei/NEIClientUtils.java b/src/codechicken/nei/NEIClientUtils.java index 469a0ec93..e672a21d7 100644 --- a/src/codechicken/nei/NEIClientUtils.java +++ b/src/codechicken/nei/NEIClientUtils.java @@ -157,7 +157,7 @@ public static void giveStack(ItemStack base, int i, boolean infinite) { ItemStack typestack = copyStack(stack, 1); if (!infinite && !canItemFitInInventory(mc().thePlayer, stack) && (mc().currentScreen instanceof GuiContainer)) { GuiContainer gui = getGuiContainer(); - List> handlerSlots = new LinkedList>(); + List> handlerSlots = new LinkedList<>(); for(INEIGuiHandler handler : GuiInfo.guiHandlers) handlerSlots.add(handler.getItemSpawnSlots(gui, typestack)); @@ -306,7 +306,7 @@ public static void toggleMagnetMode() { } public static ArrayList concatIntegersToRanges(List damages) { - ArrayList ranges = new ArrayList(); + ArrayList ranges = new ArrayList<>(); if (damages.size() == 0) return ranges; Collections.sort(damages); diff --git a/src/codechicken/nei/NEIController.java b/src/codechicken/nei/NEIController.java index 7c93ac6a1..9a35350a2 100644 --- a/src/codechicken/nei/NEIController.java +++ b/src/codechicken/nei/NEIController.java @@ -1,6 +1,10 @@ package codechicken.nei; -import codechicken.nei.api.*; +import codechicken.nei.api.API; +import codechicken.nei.api.GuiInfo; +import codechicken.nei.api.IInfiniteItemHandler; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.ItemInfo; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; import codechicken.nei.guihook.IContainerSlotClickHandler; @@ -11,14 +15,14 @@ import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; -import java.awt.*; +import java.awt.Point; import java.util.LinkedList; import static codechicken.lib.gui.GuiDraw.getMousePosition; public class NEIController implements IContainerSlotClickHandler, IContainerInputHandler { - private static NEIController instance = new NEIController(); + private static final NEIController instance = new NEIController(); public static GuiContainerManager manager; public static FastTransferManager fastTransferManager; @@ -56,7 +60,7 @@ public static void updateUnlimitedItems(InventoryPlayer inventory) { if (!NEIClientConfig.canPerformAction("item") || !NEIClientConfig.hasSMPCounterPart()) return; - LinkedList beforeStacks = new LinkedList(); + LinkedList beforeStacks = new LinkedList<>(); for (int i = 0; i < inventory.getSizeInventory(); i++) beforeStacks.add(NEIServerUtils.copyStack(inventory.getStackInSlot(i))); diff --git a/src/codechicken/nei/NEIModContainer.java b/src/codechicken/nei/NEIModContainer.java index f32293143..1fb8c1dc9 100644 --- a/src/codechicken/nei/NEIModContainer.java +++ b/src/codechicken/nei/NEIModContainer.java @@ -20,11 +20,14 @@ import net.minecraft.util.EnumChatFormatting; import java.io.File; -import java.util.*; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; public class NEIModContainer extends DummyModContainer { - public static LinkedList plugins = new LinkedList(); + public static LinkedList plugins = new LinkedList<>(); public NEIModContainer() { super(MetadataCollection.from(MetadataCollection.class.getResourceAsStream("/neimod.info"), "NotEnoughItems").getMetadataForId("NotEnoughItems", null)); @@ -33,14 +36,14 @@ public NEIModContainer() { @Override public Set getRequirements() { - Set deps = new HashSet(); + Set deps = new HashSet<>(); deps.add(VersionParser.parseVersionReference("CodeChickenCore@["+CodeChickenCorePlugin.version+",)")); return deps; } @Override public List getDependencies() { - return new LinkedList(getRequirements()); + return new LinkedList<>(getRequirements()); } private String description; @@ -50,22 +53,22 @@ private void loadMetadata() { @Override public ModMetadata getMetadata() { - String s_plugins = ""; + StringBuilder s_plugins = new StringBuilder(); if (plugins.size() == 0) { - s_plugins += EnumChatFormatting.RED+"No installed plugins."; + s_plugins.append(EnumChatFormatting.RED).append("No installed plugins."); } else { - s_plugins += EnumChatFormatting.GREEN+"Installed plugins: "; + s_plugins.append(EnumChatFormatting.GREEN).append("Installed plugins: "); for (int i = 0; i < plugins.size(); i++) { if (i > 0) - s_plugins += ", "; + s_plugins.append(", "); IConfigureNEI plugin = plugins.get(i); - s_plugins += plugin.getName() + " " + plugin.getVersion(); + s_plugins.append(plugin.getName()).append(" ").append(plugin.getVersion()); } - s_plugins += "."; + s_plugins.append("."); } ModMetadata meta = super.getMetadata(); - meta.description = description.replace("", s_plugins); + meta.description = description.replace("", s_plugins.toString()); return meta; } diff --git a/src/codechicken/nei/NEISPH.java b/src/codechicken/nei/NEISPH.java index b3bc52da8..91ed283ad 100644 --- a/src/codechicken/nei/NEISPH.java +++ b/src/codechicken/nei/NEISPH.java @@ -1,7 +1,6 @@ package codechicken.nei; import codechicken.core.CommonUtils; -import codechicken.core.IGuiPacketSender; import codechicken.core.ServerUtils; import codechicken.lib.inventory.SlotDummy; import codechicken.lib.packet.PacketCustom; @@ -112,15 +111,11 @@ private void handlePropertyChange(EntityPlayerMP sender, PacketCustom packet) { public static void processCreativeInv(EntityPlayerMP sender, boolean open) { if (open) { - ServerUtils.openSMPContainer(sender, new ContainerCreativeInv(sender, new ExtendedCreativeInv(NEIServerConfig.forPlayer(sender.getCommandSenderName()), Side.SERVER)), new IGuiPacketSender() - { - @Override - public void sendPacket(EntityPlayerMP player, int windowId) { - PacketCustom packet = new PacketCustom(channel, 23); - packet.writeBoolean(true); - packet.writeByte(windowId); - packet.sendToPlayer(player); - } + ServerUtils.openSMPContainer(sender, new ContainerCreativeInv(sender, new ExtendedCreativeInv(NEIServerConfig.forPlayer(sender.getCommandSenderName()), Side.SERVER)), (player, windowId) -> { + PacketCustom packet = new PacketCustom(channel, 23); + packet.writeBoolean(true); + packet.writeByte(windowId); + packet.sendToPlayer(player); }); } else { sender.closeContainer(); @@ -155,14 +150,10 @@ private void modifyEnchantment(EntityPlayerMP player, int e, int lvl, boolean ad } private void openEnchantmentGui(EntityPlayerMP player) { - ServerUtils.openSMPContainer(player, new ContainerEnchantmentModifier(player.inventory, player.worldObj, 0, 0, 0), new IGuiPacketSender() - { - @Override - public void sendPacket(EntityPlayerMP player, int windowId) { - PacketCustom packet = new PacketCustom(channel, 21); - packet.writeByte(windowId); - packet.sendToPlayer(player); - } + ServerUtils.openSMPContainer(player, new ContainerEnchantmentModifier(player.inventory, player.worldObj, 0, 0, 0), (player1, windowId) -> { + PacketCustom packet = new PacketCustom(channel, 21); + packet.writeByte(windowId); + packet.sendToPlayer(player1); }); } @@ -170,14 +161,10 @@ private void openPotionGui(EntityPlayerMP player, PacketCustom packet) { InventoryBasic b = new InventoryBasic("potionStore", true, 9); for (int i = 0; i < b.getSizeInventory(); i++) b.setInventorySlotContents(i, packet.readItemStack()); - ServerUtils.openSMPContainer(player, new ContainerPotionCreator(player.inventory, b), new IGuiPacketSender() - { - @Override - public void sendPacket(EntityPlayerMP player, int windowId) { - PacketCustom packet = new PacketCustom(channel, 24); - packet.writeByte(windowId); - packet.sendToPlayer(player); - } + ServerUtils.openSMPContainer(player, new ContainerPotionCreator(player.inventory, b), (player1, windowId) -> { + PacketCustom packet1 = new PacketCustom(channel, 24); + packet1.writeByte(windowId); + packet1.sendToPlayer(player1); }); } @@ -196,10 +183,10 @@ public static void sendActionEnabled(EntityPlayerMP player, String name, boolean } private void sendLoginState(EntityPlayerMP player) { - LinkedList actions = new LinkedList(); - LinkedList disabled = new LinkedList(); - LinkedList enabled = new LinkedList(); - LinkedList bannedItems = new LinkedList(); + LinkedList actions = new LinkedList<>(); + LinkedList disabled = new LinkedList<>(); + LinkedList enabled = new LinkedList<>(); + LinkedList bannedItems = new LinkedList<>(); PlayerSave playerSave = NEIServerConfig.forPlayer(player.getCommandSenderName()); for (String name : NEIActions.nameActionMap.keySet()) { diff --git a/src/codechicken/nei/NEIServerConfig.java b/src/codechicken/nei/NEIServerConfig.java index 65a6c7053..6f9015568 100644 --- a/src/codechicken/nei/NEIServerConfig.java +++ b/src/codechicken/nei/NEIServerConfig.java @@ -21,7 +21,14 @@ import java.io.File; import java.io.FileReader; import java.io.PrintWriter; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; public class NEIServerConfig { @@ -30,9 +37,9 @@ public class NEIServerConfig public static Logger logger = LogManager.getLogger("NotEnoughItems"); public static File saveDir; public static ConfigFile serverConfig; - public static Map dimTags = new HashMap(); - public static HashMap playerSaves = new HashMap(); - public static ItemStackMap> bannedItems = new ItemStackMap>(); + public static Map dimTags = new HashMap<>(); + public static HashMap playerSaves = new HashMap<>(); + public static ItemStackMap> bannedItems = new ItemStackMap<>(); public static void load(World world) { if (MinecraftServer.getServer() != server) { @@ -89,13 +96,13 @@ private static void setDefaultFeature(String featurename, String... names) { if (names.length == 0) names = new String[]{"OP"}; - String list = ""; + StringBuilder list = new StringBuilder(); for (int i = 0; i < names.length; i++) { if (i >= 1) - list += ", "; - list += names[i]; + list.append(", "); + list.append(names[i]); } - serverConfig.getTag("permissions." + featurename).setDefaultValue(list); + serverConfig.getTag("permissions." + featurename).setDefaultValue(list.toString()); } private static void saveWorld(int dim) { @@ -139,7 +146,7 @@ public static void disableAction(int dim, String name, boolean disable) { public static HashSet getPlayerList(String tag) { String[] list = serverConfig.getTag(tag).getValue("").replace(" ", "").split(","); - return new HashSet(Arrays.asList(list)); + return new HashSet<>(Arrays.asList(list)); } public static void addPlayerToList(String playername, String tag) { @@ -179,7 +186,7 @@ private static void loadBannedItems() { bannedItems.clear(); File file = new File(saveDir, "banneditems.cfg"); if(!file.exists()) { - bannedItems.put(new ItemStack(Blocks.command_block), new HashSet(Arrays.asList("NONE"))); + bannedItems.put(new ItemStack(Blocks.command_block), new HashSet<>(Collections.singletonList("NONE"))); saveBannedItems(); return; } @@ -196,7 +203,7 @@ private static void loadBannedItems() { } try { NBTTagCompound key = (NBTTagCompound) JsonToNBT.func_150315_a(s.substring(0, delim)); - Set values = new HashSet(); + Set values = new HashSet<>(); for(String s2 : s.substring(delim+1).split(",")) values.add(s2.trim()); bannedItems.put(InventoryUtils.loadPersistant(key), values); diff --git a/src/codechicken/nei/NEIServerUtils.java b/src/codechicken/nei/NEIServerUtils.java index 9a941e7f6..23e36bd12 100644 --- a/src/codechicken/nei/NEIServerUtils.java +++ b/src/codechicken/nei/NEIServerUtils.java @@ -25,8 +25,16 @@ import net.minecraft.world.WorldSettings.GameType; import net.minecraftforge.oredict.OreDictionary; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; import java.util.zip.ZipException; public class NEIServerUtils @@ -287,7 +295,7 @@ public static void cycleCreativeInv(EntityPlayerMP player, int steps) { } public static List getEnchantments(ItemStack itemstack) { - ArrayList arraylist = new ArrayList(); + ArrayList arraylist = new ArrayList<>(); if (itemstack != null) { NBTTagList nbttaglist = itemstack.getEnchantmentTagList(); if (nbttaglist != null) diff --git a/src/codechicken/nei/OffsetPositioner.java b/src/codechicken/nei/OffsetPositioner.java index a76f9f3a4..d3b74c186 100644 --- a/src/codechicken/nei/OffsetPositioner.java +++ b/src/codechicken/nei/OffsetPositioner.java @@ -24,5 +24,5 @@ public ArrayList positionStacks(ArrayList ai) } public int offsetx; - public int offsety; + public int offsety; } diff --git a/src/codechicken/nei/PlayerSave.java b/src/codechicken/nei/PlayerSave.java index c4d5da99e..473abba18 100644 --- a/src/codechicken/nei/PlayerSave.java +++ b/src/codechicken/nei/PlayerSave.java @@ -4,7 +4,6 @@ import codechicken.lib.inventory.InventoryUtils; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; diff --git a/src/codechicken/nei/PositionedStack.java b/src/codechicken/nei/PositionedStack.java index 4aa997aae..f9fea7894 100644 --- a/src/codechicken/nei/PositionedStack.java +++ b/src/codechicken/nei/PositionedStack.java @@ -16,7 +16,7 @@ public class PositionedStack { public int relx; public int rely; - public ItemStack items[]; + public ItemStack[] items; //compatibility dummy public ItemStack item; @@ -44,7 +44,7 @@ public void generatePermutations() if(permutated) return; - ArrayList stacks = new ArrayList(); + ArrayList stacks = new ArrayList<>(); for(ItemStack item : items) { if(item == null || item.getItem() == null) diff --git a/src/codechicken/nei/SearchField.java b/src/codechicken/nei/SearchField.java index a86e2e607..e75998f75 100644 --- a/src/codechicken/nei/SearchField.java +++ b/src/codechicken/nei/SearchField.java @@ -48,7 +48,7 @@ public ItemFilter getFilter(String searchText) { } } - public static List searchProviders = new LinkedList(); + public static List searchProviders = new LinkedList<>(); long lastclicktime; @@ -142,8 +142,8 @@ public static Pattern getPattern(String search) { public ItemFilter getFilter() { String s_filter = text().toLowerCase(); - List primary = new LinkedList(); - List secondary = new LinkedList(); + List primary = new LinkedList<>(); + List secondary = new LinkedList<>(); for (ISearchProvider p : searchProviders) { ItemFilter filter = p.getFilter(s_filter); if (filter != null) diff --git a/src/codechicken/nei/SpawnerRenderer.java b/src/codechicken/nei/SpawnerRenderer.java index afabf6505..e236d2ad6 100644 --- a/src/codechicken/nei/SpawnerRenderer.java +++ b/src/codechicken/nei/SpawnerRenderer.java @@ -2,7 +2,6 @@ import codechicken.core.ClientUtils; import codechicken.lib.render.CCRenderState; -import codechicken.lib.render.TextureUtils; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; diff --git a/src/codechicken/nei/SubsetWidget.java b/src/codechicken/nei/SubsetWidget.java index 42f340563..d2b8fdf88 100644 --- a/src/codechicken/nei/SubsetWidget.java +++ b/src/codechicken/nei/SubsetWidget.java @@ -36,7 +36,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa public static class SubsetState { int state = 2; - ArrayList items = new ArrayList(); + ArrayList items = new ArrayList<>(); } public static class SubsetTag @@ -128,7 +128,7 @@ public int scrollbarGuideAlignment() { public final String fullname; public final ItemFilter filter; - public TreeMap children = new TreeMap(); + public TreeMap children = new TreeMap<>(); public List sorted = Collections.emptyList(); private int childwidth; @@ -177,7 +177,7 @@ private SubsetTag getTag(String name) { } private void recacheChildren() { - sorted = new ArrayList(children.values()); + sorted = new ArrayList<>(children.values()); childwidth = 0; for(SubsetTag tag : sorted) childwidth = Math.max(childwidth, tag.nameWidth()+2); @@ -372,12 +372,12 @@ public boolean isScrolling() { public static Rectangle4i area = new Rectangle4i(); public static ItemStack hoverStack; - private static HashMap subsetState = new HashMap(); + private static HashMap subsetState = new HashMap<>(); /** * All operations on this variable should be synchronised. */ private static final ItemStackSet hiddenItems = new ItemStackSet(); - private static final AtomicReference dirtyHiddenItems = new AtomicReference(); + private static final AtomicReference dirtyHiddenItems = new AtomicReference<>(); public static SubsetState getState(SubsetTag tag) { SubsetState state = subsetState.get(tag.fullname); @@ -388,6 +388,7 @@ public static void addTag(SubsetTag tag) { updateState.stop(); synchronized (root) { root.addTag(tag); + NEIClientConfig.logger.info("Adding Tag {}", tag.displayName()); updateState.reallocate(); } } @@ -455,7 +456,7 @@ public static void loadHidden() { hiddenItems.clear(); } - List itemList = new LinkedList(); + List itemList = new LinkedList<>(); try { NBTTagList list = NEIClientConfig.world.nbt.getTagList("hiddenItems", 10); for(int i = 0; i < list.tagCount(); i++) @@ -524,8 +525,8 @@ public synchronized void reallocate() { @Override public void execute() { - HashMap state = new HashMap(); - List tags = new LinkedList(); + HashMap state = new HashMap<>(); + List tags = new LinkedList<>(); synchronized (root) { cloneStates(root, tags, state); if(interrupted()) return; @@ -728,7 +729,7 @@ public ItemFilter getFilter(String searchText) { Pattern p = SearchField.getPattern(searchText); if(p == null) return null; - List matching = new LinkedList(); + List matching = new LinkedList<>(); root.search(matching, p); if(matching.isEmpty()) return null; for(SubsetTag tag2 : matching) diff --git a/src/codechicken/nei/TextField.java b/src/codechicken/nei/TextField.java index f5f9fb2c6..436c5954f 100644 --- a/src/codechicken/nei/TextField.java +++ b/src/codechicken/nei/TextField.java @@ -1,14 +1,12 @@ package codechicken.nei; -import cpw.mods.fml.client.config.HoverChecker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiTextField; import org.lwjgl.input.Keyboard; public abstract class TextField extends Widget { - protected GuiTextField field; - protected final HoverChecker hoverChecker; + protected final GuiTextField field; private static final int maxSearchLength = 256; @@ -21,7 +19,6 @@ 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); } diff --git a/src/codechicken/nei/ThreadOperationTimer.java b/src/codechicken/nei/ThreadOperationTimer.java index fa774862f..1aa851252 100644 --- a/src/codechicken/nei/ThreadOperationTimer.java +++ b/src/codechicken/nei/ThreadOperationTimer.java @@ -16,7 +16,7 @@ public TimeoutException(String msg, Object op) { } } - private Thread thread; + private final Thread thread; private Object operation; private long opTime; private long limit; diff --git a/src/codechicken/nei/WidgetZOrder.java b/src/codechicken/nei/WidgetZOrder.java index e6679f018..da5587207 100644 --- a/src/codechicken/nei/WidgetZOrder.java +++ b/src/codechicken/nei/WidgetZOrder.java @@ -5,7 +5,7 @@ public class WidgetZOrder implements Comparator { - boolean topfirst; + final boolean topfirst; public WidgetZOrder(boolean topfirst) { this.topfirst = topfirst; diff --git a/src/codechicken/nei/WorldOverlayRenderer.java b/src/codechicken/nei/WorldOverlayRenderer.java index 2bac58995..8887f68d9 100644 --- a/src/codechicken/nei/WorldOverlayRenderer.java +++ b/src/codechicken/nei/WorldOverlayRenderer.java @@ -98,8 +98,8 @@ private static void renderMobSpawnOverlay(Entity entity) { GL11.glDisable(GL11.GL_BLEND); } - private static Entity dummyEntity = new EntityPig(null); - private static AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); + private static final Entity dummyEntity = new EntityPig(null); + private static final AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); private static int getSpawnMode(Chunk chunk, int x, int y, int z) { if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z) || chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8) diff --git a/src/codechicken/nei/api/DefaultOverlayRenderer.java b/src/codechicken/nei/api/DefaultOverlayRenderer.java index 894e2efee..4c804b6e3 100644 --- a/src/codechicken/nei/api/DefaultOverlayRenderer.java +++ b/src/codechicken/nei/api/DefaultOverlayRenderer.java @@ -13,7 +13,7 @@ public class DefaultOverlayRenderer implements IRecipeOverlayRenderer public DefaultOverlayRenderer(List ai, IStackPositioner positioner) { positioner = this.positioner = positioner; - ingreds = new ArrayList(); + ingreds = new ArrayList<>(); for(PositionedStack stack : ai) ingreds.add(stack.copy()); ingreds = positioner.positionStacks(ingreds); @@ -39,6 +39,6 @@ public void renderOverlay(GuiContainerManager gui, Slot slot) GL11.glEnable(GL11.GL_LIGHTING); } - IStackPositioner positioner; + final IStackPositioner positioner; ArrayList ingreds; } diff --git a/src/codechicken/nei/api/GuiInfo.java b/src/codechicken/nei/api/GuiInfo.java index 38883523a..059d827d9 100644 --- a/src/codechicken/nei/api/GuiInfo.java +++ b/src/codechicken/nei/api/GuiInfo.java @@ -12,8 +12,8 @@ public class GuiInfo { - public static LinkedList guiHandlers = new LinkedList(); - public static HashSet> customSlotGuis = new HashSet>(); + public static final LinkedList guiHandlers = new LinkedList<>(); + public static final HashSet> customSlotGuis = new HashSet<>(); public static void load() { API.registerNEIGuiHandler(new NEICreativeGuiHandler()); diff --git a/src/codechicken/nei/api/ItemInfo.java b/src/codechicken/nei/api/ItemInfo.java index 008eb7f4e..a50079cce 100644 --- a/src/codechicken/nei/api/ItemInfo.java +++ b/src/codechicken/nei/api/ItemInfo.java @@ -1,9 +1,14 @@ package codechicken.nei.api; import codechicken.core.featurehack.GameDataManipulator; -import codechicken.nei.*; -import codechicken.nei.ItemList.ItemsLoadedCallback; -import codechicken.nei.api.ItemFilter.ItemFilterProvider; +import codechicken.nei.InfiniteStackSizeHandler; +import codechicken.nei.InfiniteToolHandler; +import codechicken.nei.ItemList; +import codechicken.nei.ItemMobSpawner; +import codechicken.nei.ItemStackMap; +import codechicken.nei.ItemStackSet; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PopupInputHandler; import codechicken.nei.config.ArrayDumper; import codechicken.nei.config.ItemPanelDumper; import codechicken.nei.config.RegistryDumper; @@ -27,7 +32,15 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Slot; -import net.minecraft.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.potion.Potion; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MovingObjectPosition; @@ -38,7 +51,11 @@ import net.minecraftforge.common.IShearable; import net.minecraftforge.oredict.OreDictionary; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map.Entry; /** @@ -52,20 +69,20 @@ public static enum Layout } public static final ArrayListMultimap highlightHandlers = ArrayListMultimap.create(); - public static final ItemStackMap nameOverrides = new ItemStackMap(); + public static final ItemStackMap nameOverrides = new ItemStackMap<>(); public static final ItemStackSet hiddenItems = new ItemStackSet(); public static final ItemStackSet finiteItems = new ItemStackSet(); public static final ArrayListMultimap itemOverrides = ArrayListMultimap.create(); public static final ArrayListMultimap itemVariants = ArrayListMultimap.create(); - public static final LinkedList infiniteHandlers = new LinkedList(); + public static final LinkedList infiniteHandlers = new LinkedList<>(); public static final ArrayListMultimap highlightIdentifiers = ArrayListMultimap.create(); - public static final HashSet> fastTransferExemptions = new HashSet>(); + public static final HashSet> fastTransferExemptions = new HashSet<>(); - public static final HashMap itemOwners = new HashMap(); + public static final HashMap itemOwners = new HashMap<>(); //lookup optimisation - public static final HashMap itemSearchNames = new HashMap(); + public static final HashMap itemSearchNames = new HashMap<>(); public static boolean isHidden(ItemStack stack) { return hiddenItems.contains(stack); @@ -111,28 +128,11 @@ public static void load(World world) { } private static void addSearchOptimisation() { - ItemList.loadCallbacks.add(new ItemsLoadedCallback() - { - @Override public void itemsLoaded() { - itemSearchNames.clear(); - } - }); + ItemList.loadCallbacks.add(itemSearchNames::clear); } private static void addHiddenItemFilter() { - API.addItemFilter(new ItemFilterProvider() - { - @Override - public ItemFilter getFilter() { - return new ItemFilter() - { - @Override - public boolean matches(ItemStack item) { - return !hiddenItems.contains(item); - } - }; - } - }); + API.addItemFilter(() -> item -> !hiddenItems.contains(item)); } private static void addIDDumps() { @@ -264,7 +264,7 @@ public BiomeGenBase[] array() { } private static void parseModItems() { - HashMap modSubsets = new HashMap(); + HashMap modSubsets = new HashMap<>(); for (Item item : (Iterable) Item.itemRegistry) { UniqueIdentifier ident = null; try { @@ -323,20 +323,8 @@ private static void addVanillaBlockProperties() { } private static void addDefaultDropDowns() { - API.addSubset("Items", new ItemFilter() - { - @Override - public boolean matches(ItemStack item) { - return Block.getBlockFromItem(item.getItem()) == Blocks.air; - } - }); - API.addSubset("Blocks", new ItemFilter() - { - @Override - public boolean matches(ItemStack item) { - return Block.getBlockFromItem(item.getItem()) != Blocks.air; - } - }); + API.addSubset("Items", item -> Block.getBlockFromItem(item.getItem()) == Blocks.air); + API.addSubset("Blocks", item -> Block.getBlockFromItem(item.getItem()) != Blocks.air); API.addSubset("Blocks.MobSpawners", ItemStackSet.of(Blocks.mob_spawner)); } @@ -356,8 +344,8 @@ private static void searchItems() { ItemStackSet food = new ItemStackSet(); ItemStackSet potioningredients = new ItemStackSet(); - ArrayList creativeTabRanges = new ArrayList(CreativeTabs.creativeTabArray.length); - List stackList = new LinkedList(); + ArrayList creativeTabRanges = new ArrayList<>(CreativeTabs.creativeTabArray.length); + List stackList = new LinkedList<>(); for (Item item : (Iterable) Item.itemRegistry) { if (item == null) @@ -419,7 +407,7 @@ else if (item == Items.fishing_rod || item == Items.flint_and_steel || item == I food.with(item); try { - LinkedList subItems = new LinkedList(); + LinkedList subItems = new LinkedList<>(); item.getSubItems(item, null, subItems); for(ItemStack stack : subItems) { if (item.isPotionIngredient(stack) && item.getPotionEffect(stack) != null) { @@ -473,9 +461,9 @@ public static ArrayList getIdentifierItems(World world, EntityPlayer int z = hit.blockZ; Block mouseoverBlock = world.getBlock(x, y, z); - ArrayList items = new ArrayList(); + ArrayList items = new ArrayList<>(); - ArrayList handlers = new ArrayList(); + ArrayList handlers = new ArrayList<>(); if (highlightIdentifiers.containsKey(null)) handlers.addAll(highlightIdentifiers.get(null)); if (highlightIdentifiers.containsKey(mouseoverBlock)) @@ -514,7 +502,7 @@ public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo. } public static List getText(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop) { - List retString = new ArrayList(); + List retString = new ArrayList<>(); for (ItemInfo.Layout layout : ItemInfo.Layout.values()) for (IHighlightHandler handler : ItemInfo.highlightHandlers.get(layout)) diff --git a/src/codechicken/nei/api/NEIInfo.java b/src/codechicken/nei/api/NEIInfo.java index 77898df79..606c2feed 100644 --- a/src/codechicken/nei/api/NEIInfo.java +++ b/src/codechicken/nei/api/NEIInfo.java @@ -8,7 +8,7 @@ public class NEIInfo { - public static final LinkedList modeHandlers = new LinkedList(); + public static final LinkedList modeHandlers = new LinkedList<>(); public static void load(World world) { OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode"); diff --git a/src/codechicken/nei/api/TaggedInventoryArea.java b/src/codechicken/nei/api/TaggedInventoryArea.java index b50d2e239..b45fd5d87 100644 --- a/src/codechicken/nei/api/TaggedInventoryArea.java +++ b/src/codechicken/nei/api/TaggedInventoryArea.java @@ -9,8 +9,8 @@ public class TaggedInventoryArea { - public HashSet slots = new HashSet(); - public String tagName; + public final HashSet slots = new HashSet<>(); + public final String tagName; /** * Only for player inventories. */ @@ -18,7 +18,7 @@ public class TaggedInventoryArea /** * Other inventories */ - private Container container; + private final Container container; public TaggedInventoryArea(InventoryPlayer invPlayer) { diff --git a/src/codechicken/nei/asm/NEITransformer.java b/src/codechicken/nei/asm/NEITransformer.java index e50ea5a45..2e56b73bc 100644 --- a/src/codechicken/nei/asm/NEITransformer.java +++ b/src/codechicken/nei/asm/NEITransformer.java @@ -1,18 +1,43 @@ package codechicken.nei.asm; -import codechicken.lib.asm.*; -import codechicken.lib.asm.ModularASMTransformer.*; +import codechicken.lib.asm.ASMBlock; +import codechicken.lib.asm.ASMHelper; +import codechicken.lib.asm.ASMInit; +import codechicken.lib.asm.ASMReader; +import codechicken.lib.asm.ClassHeirachyManager; +import codechicken.lib.asm.InsnListSection; +import codechicken.lib.asm.ModularASMTransformer; +import codechicken.lib.asm.ModularASMTransformer.FieldWriter; +import codechicken.lib.asm.ModularASMTransformer.MethodInjector; +import codechicken.lib.asm.ModularASMTransformer.MethodReplacer; +import codechicken.lib.asm.ModularASMTransformer.MethodTransformer; +import codechicken.lib.asm.ModularASMTransformer.MethodWriter; +import codechicken.lib.asm.ObfMapping; import cpw.mods.fml.relauncher.FMLLaunchHandler; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; import java.util.Map; -import static codechicken.lib.asm.InsnComparator.*; +import static codechicken.lib.asm.InsnComparator.findN; +import static codechicken.lib.asm.InsnComparator.findOnce; +import static codechicken.lib.asm.InsnComparator.getControlFlowLabels; +import static codechicken.lib.asm.InsnComparator.matches; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS; -import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ILOAD; +import static org.objectweb.asm.Opcodes.INVOKESPECIAL; +import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; +import static org.objectweb.asm.Opcodes.IRETURN; public class NEITransformer implements IClassTransformer { @@ -20,8 +45,8 @@ public class NEITransformer implements IClassTransformer ASMInit.init(); } - private ModularASMTransformer transformer = new ModularASMTransformer(); - private Map asmblocks = ASMReader.loadResource("/assets/nei/asm/blocks.asm"); + private final ModularASMTransformer transformer = new ModularASMTransformer(); + private final Map asmblocks = ASMReader.loadResource("/assets/nei/asm/blocks.asm"); public NEITransformer() { if(FMLLaunchHandler.side().isClient()) { @@ -199,7 +224,7 @@ private void addProtectedForwarder(ObfMapping called, ObfMapping caller) { transformer.add(new MethodWriter(ACC_PUBLIC, publicCall, forward2)); } - private ObfMapping c_GuiContainer = new ObfMapping("net/minecraft/client/gui/inventory/GuiContainer").toClassloading(); + private final ObfMapping c_GuiContainer = new ObfMapping("net/minecraft/client/gui/inventory/GuiContainer").toClassloading(); /** * Adds super.updateScreen() to non implementing GuiContainer subclasses */ diff --git a/src/codechicken/nei/config/ArrayDumper.java b/src/codechicken/nei/config/ArrayDumper.java index 46c254371..c5bf3bbc1 100644 --- a/src/codechicken/nei/config/ArrayDumper.java +++ b/src/codechicken/nei/config/ArrayDumper.java @@ -10,7 +10,7 @@ public ArrayDumper(String name) { @Override public Iterable dump(int mode) { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); T[] array = array(); for (int i = 0; i < array.length; i++) { T obj = array[i]; diff --git a/src/codechicken/nei/config/ConfigSet.java b/src/codechicken/nei/config/ConfigSet.java index 9d4277db4..4a358857c 100644 --- a/src/codechicken/nei/config/ConfigSet.java +++ b/src/codechicken/nei/config/ConfigSet.java @@ -2,16 +2,15 @@ import codechicken.lib.config.ConfigTagParent; import codechicken.nei.NEIServerUtils; -import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import java.io.File; public class ConfigSet { - private File nbtFile; + private final File nbtFile; public NBTTagCompound nbt; - public ConfigTagParent config; + public final ConfigTagParent config; public ConfigSet(File nbtFile, ConfigTagParent config) { this.nbtFile = nbtFile; diff --git a/src/codechicken/nei/config/GuiHighlightTips.java b/src/codechicken/nei/config/GuiHighlightTips.java index 03b408809..063a249a9 100644 --- a/src/codechicken/nei/config/GuiHighlightTips.java +++ b/src/codechicken/nei/config/GuiHighlightTips.java @@ -11,7 +11,8 @@ import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; -import java.awt.*; +import java.awt.Dimension; +import java.awt.Point; import java.util.Arrays; import java.util.List; @@ -21,9 +22,9 @@ public class GuiHighlightTips extends GuiScreenWidget { - private String name; + private final String name; private GuiCCButton toggleButton; - private Option opt; + private final Option opt; private Point dragDown; public GuiHighlightTips(Option opt) { diff --git a/src/codechicken/nei/config/GuiItemIconDumper.java b/src/codechicken/nei/config/GuiItemIconDumper.java index 8a0689cf7..083799747 100644 --- a/src/codechicken/nei/config/GuiItemIconDumper.java +++ b/src/codechicken/nei/config/GuiItemIconDumper.java @@ -39,7 +39,7 @@ public class GuiItemIconDumper extends GuiScreen private Option opt; private int drawIndex; private int parseIndex; - private File dir = new File(CommonUtils.getMinecraftDir(), "dumps/itempanel_icons"); + private final File dir = new File(CommonUtils.getMinecraftDir(), "dumps/itempanel_icons"); private int iconSize; private int borderSize; private int boxSize; @@ -127,7 +127,7 @@ private void exportItems() throws IOException { public static String cleanFileName(String name) { StringBuilder cleanName = new StringBuilder(); for (int i = 0; i < name.length(); i++) { - int c = (int)name.charAt(i); + int c = name.charAt(i); if (Arrays.binarySearch(illegalChars, c) < 0) cleanName.append((char)c); else diff --git a/src/codechicken/nei/config/GuiItemSorter.java b/src/codechicken/nei/config/GuiItemSorter.java index 8e870fc9d..25ed1328b 100644 --- a/src/codechicken/nei/config/GuiItemSorter.java +++ b/src/codechicken/nei/config/GuiItemSorter.java @@ -20,7 +20,7 @@ public class SortItem { public double ya; public double y; - public SortEntry e; + public final SortEntry e; public SortItem(SortEntry e) { this.e = e; @@ -45,9 +45,9 @@ public boolean contains(int my) { } } - public Option opt; - public List slots = new ArrayList(); - public List list; + public final Option opt; + public final List slots = new ArrayList<>(); + public final List list; boolean dragging; public SortItem dragged; @@ -120,7 +120,7 @@ public void updateScreen() { list.add(nslot, dragged.e); opt.getTag().setValue(ItemSorter.getSaveString(list)); if(opt.activeTag() == opt.getTag()) - ItemSorter.list = new ArrayList(list); + ItemSorter.list = new ArrayList<>(list); } } } diff --git a/src/codechicken/nei/config/GuiOptionList.java b/src/codechicken/nei/config/GuiOptionList.java index 66b6cd58c..1cb4e492d 100644 --- a/src/codechicken/nei/config/GuiOptionList.java +++ b/src/codechicken/nei/config/GuiOptionList.java @@ -27,7 +27,7 @@ public class GuiOptionList extends GuiScreenWidget { public class OptionScrollSlot extends GuiScrollSlot { - public ArrayList