diff --git a/LICENSE.NewHorizonsCoreMod b/LICENSE.NewHorizonsCoreMod
new file mode 100644
index 0000000..ef7e7ef
--- /dev/null
+++ b/LICENSE.NewHorizonsCoreMod
@@ -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.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+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:
+
+ {project} Copyright (C) {year} {fullname}
+ 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
+.
diff --git a/README.md b/README.md
index 3f16529..5bcf4d8 100644
--- a/README.md
+++ b/README.md
@@ -18,4 +18,10 @@ This can be used as a standalone mod with several dependencies. The vending mach
## Credits
-We would like to thank the contributors of BetterQuesting for their implementation of networking and file serialization/deserialization, which are used in this project. We do not reference the classes directly to avoid having BetterQuesting as a required dependency. The BetterQuesting license may be found in the root directory of this project as LICENSE.betterquesting.
+Credits to **BetterQuesting** for their implementation of networking and file serialization/deserialization, which are used in this project. We do not reference the classes directly to avoid having BetterQuesting as a required dependency.
+
+Credits to **NH Coremod** for the coin textures used in the GUI.
+
+The BetterQuesting license may be found in the root directory of this project as LICENSE.betterquesting.
+
+The NHCoreMod licenese may be found in the root directory of this project as LICENSE.NewHorizonsCoreMod.
diff --git a/src/main/java/com/cubefury/vendingmachine/ClientProxy.java b/src/main/java/com/cubefury/vendingmachine/ClientProxy.java
index 2e6bd39..a64f4a3 100644
--- a/src/main/java/com/cubefury/vendingmachine/ClientProxy.java
+++ b/src/main/java/com/cubefury/vendingmachine/ClientProxy.java
@@ -1,11 +1,9 @@
package com.cubefury.vendingmachine;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
import com.cubefury.vendingmachine.integration.nei.NEIConfig;
-import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -28,12 +26,6 @@ public boolean isClient() {
return true;
}
- @Override
- public EntityPlayer getThePlayer() {
- return FMLClientHandler.instance()
- .getClientPlayerEntity();
- }
-
@Override
public void registerHandlers() {
super.registerHandlers();
diff --git a/src/main/java/com/cubefury/vendingmachine/CommonProxy.java b/src/main/java/com/cubefury/vendingmachine/CommonProxy.java
index a075743..fe27b2d 100644
--- a/src/main/java/com/cubefury/vendingmachine/CommonProxy.java
+++ b/src/main/java/com/cubefury/vendingmachine/CommonProxy.java
@@ -2,7 +2,6 @@
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.MinecraftForge;
@@ -49,8 +48,4 @@ public void registerHandlers() {
.bus()
.register(EventHandler.INSTANCE);
}
-
- public EntityPlayer getThePlayer() {
- return null;
- }
}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java
index f329527..5181784 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java
@@ -3,13 +3,19 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.ChatComponentTranslation;
+import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
@@ -23,8 +29,11 @@
import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync;
import com.cubefury.vendingmachine.network.handlers.NetTradeRequestSync;
import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync;
+import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.Trade;
import com.cubefury.vendingmachine.trade.TradeDatabase;
+import com.cubefury.vendingmachine.trade.TradeManager;
import com.cubefury.vendingmachine.trade.TradeRequest;
import com.cubefury.vendingmachine.util.BigItemStack;
import com.gtnewhorizon.structurelib.StructureLibAPI;
@@ -45,14 +54,13 @@
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.MTEMultiBlockBase;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GTUtil;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
public class MTEVendingMachine extends MTEMultiBlockBase
implements ISurvivalConstructable, ISecondaryDescribable, IAlignment {
- public static final int CUSTOM_UI_HEIGHT = 300;
-
public static final int INPUT_SLOTS = 6;
public static final int OUTPUT_SLOTS = 4;
@@ -88,6 +96,8 @@ public class MTEVendingMachine extends MTEMultiBlockBase
private boolean newBufferedOutputs = false;
private int ticksSinceOutput = 0;
+ private EntityPlayer currentUser = null;
+
public MTEVendingMachine(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -106,7 +116,6 @@ public void sendTradeRequest(TradeItemDisplay trade) {
}
public void addTradeRequest(TradeRequest trade) {
- VendingMachine.LOG.info("received new trade request");
this.pendingTrades.add(trade);
}
@@ -196,6 +205,21 @@ private boolean processTradeOnServer(TradeRequest tradeRequest) {
Trade trade = TradeDatabase.INSTANCE.getTradeGroupFromId(tradeRequest.tradeGroup)
.getTrades()
.get(tradeRequest.tradeGroupOrder);
+ Map coinInventory = TradeManager.INSTANCE.playerCurrency
+ .get(NameCache.INSTANCE.getUUIDFromPlayer(this.getCurrentUser()));
+ Map newCoinInventory = new HashMap<>();
+ if (coinInventory == null) {
+ return false;
+ }
+ for (CurrencyItem ci : trade.fromCurrency) {
+ int oldValue = coinInventory.get(ci.type);
+ if (!coinInventory.containsKey(ci.type) || oldValue < ci.value) {
+ return false;
+ } else {
+ newCoinInventory.put(ci.type, oldValue - ci.value);
+ }
+ }
+
for (BigItemStack stack : trade.fromItems) {
ItemStack requiredStack = stack.getBaseStack();
int requiredAmount = stack.stackSize;
@@ -224,6 +248,14 @@ private boolean processTradeOnServer(TradeRequest tradeRequest) {
}
}
+ for (Map.Entry entry : newCoinInventory.entrySet()) {
+ if (entry.getValue() == 0) {
+ coinInventory.remove(entry.getKey());
+ } else {
+ coinInventory.replace(entry.getKey(), entry.getValue());
+ }
+ }
+
for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) {
this.inputItems.setStackInSlot(i, inputSlots[i]);
}
@@ -278,12 +310,7 @@ protected boolean forceUseMui2() {
NetAvailableTradeSync.requestSync();
NetTradeStateSync.requestSync();
}
- return new MTEVendingMachineGui(this, CUSTOM_UI_HEIGHT);
- }
-
- @Override
- public int getGUIHeight() {
- return CUSTOM_UI_HEIGHT;
+ return new MTEVendingMachineGui(this);
}
@Override
@@ -476,4 +503,71 @@ public void construct(ItemStack stackSize, boolean hintsOnly) {
0,
hintsOnly);
}
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (GTUtil.hasMultiblockInputConfiguration(aPlayer.getHeldItem())) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (GTUtil.loadMultiblockInputConfiguration(this, aPlayer)) {
+ aPlayer.addChatComponentMessage(new ChatComponentTranslation("GT5U.MULTI_MACHINE_CONFIG.LOAD"));
+ } else {
+ aPlayer
+ .addChatComponentMessage(new ChatComponentTranslation("GT5U.MULTI_MACHINE_CONFIG.LOAD.FAIL"));
+ }
+ }
+ return true;
+ }
+ if (canUse(aPlayer)) {
+ this.currentUser = aPlayer;
+ openGui(aPlayer);
+ } else {
+ aPlayer.addChatComponentMessage(new ChatComponentTranslation("vendingmachine.gui.error.player_using"));
+ }
+ return true;
+ }
+
+ private boolean canUse(EntityPlayer aPlayer) {
+ return this.currentUser == null || this.currentUser == aPlayer;
+ }
+
+ public EntityPlayer getCurrentUser() {
+ return this.currentUser;
+ }
+
+ public void resetCurrentUser(EntityPlayer aPlayer) {
+ if (this.currentUser == aPlayer) {
+ this.currentUser = null;
+ }
+ }
+
+ public void spawnItem(ItemStack stack) {
+ if (stack == null || this.getBaseMetaTileEntity() == null) {
+ return;
+ }
+ World world = this.getBaseMetaTileEntity()
+ .getWorld();
+ int posX = this.getBaseMetaTileEntity()
+ .getXCoord();
+ int posY = this.getBaseMetaTileEntity()
+ .getYCoord();
+ int posZ = this.getBaseMetaTileEntity()
+ .getZCoord();
+ int offsetX = this.getExtendedFacing()
+ .getDirection().offsetX;
+ int offsetY = this.getExtendedFacing()
+ .getDirection().offsetY;
+ int offsetZ = this.getExtendedFacing()
+ .getDirection().offsetZ;
+ final EntityItem itemEntity = new EntityItem(
+ world,
+ posX + offsetX * 0.5,
+ posY + offsetY * 0.5,
+ posZ + offsetZ * 0.5,
+ stack);
+ itemEntity.delayBeforeCanPickup = 0;
+ itemEntity.motionX = 0.05f * offsetX;
+ itemEntity.motionY = 0.05f * offsetY;
+ itemEntity.motionZ = 0.05f * offsetZ;
+ world.spawnEntityInWorld(itemEntity);
+ }
}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java
new file mode 100644
index 0000000..88f4b14
--- /dev/null
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java
@@ -0,0 +1,42 @@
+package com.cubefury.vendingmachine.blocks.gui;
+
+import org.jetbrains.annotations.NotNull;
+
+import com.cleanroommc.modularui.api.drawable.IDrawable;
+import com.cleanroommc.modularui.api.widget.Interactable;
+import com.cleanroommc.modularui.widgets.ToggleButton;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
+
+public class CoinButton extends ToggleButton {
+
+ private final TradeMainPanel panel;
+ private final CurrencyItem.CurrencyType type;
+
+ public CoinButton(TradeMainPanel panel, CurrencyItem.CurrencyType type) {
+ super();
+ background(IDrawable.EMPTY);
+ selectedBackground(IDrawable.EMPTY);
+
+ this.panel = panel;
+ this.type = type;
+ }
+
+ @Override
+ public @NotNull Result onMousePressed(int mouseButton) {
+ if (!panel.shiftHeld) {
+ return Result.IGNORE;
+ }
+ switch (mouseButton) {
+ case 0:
+ next();
+ Interactable.playButtonClickSound();
+ return Result.SUCCESS;
+ case 1:
+ prev();
+ Interactable.playButtonClickSound();
+ return Result.SUCCESS;
+ }
+ return Result.IGNORE;
+ }
+
+}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java
new file mode 100644
index 0000000..e040010
--- /dev/null
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java
@@ -0,0 +1,41 @@
+package com.cubefury.vendingmachine.blocks.gui;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+
+import com.cleanroommc.modularui.utils.item.ItemStackHandler;
+import com.cleanroommc.modularui.widgets.slot.ModularSlot;
+import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync;
+import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
+import com.cubefury.vendingmachine.trade.TradeManager;
+
+public class InterceptingSlot extends ModularSlot {
+
+ public InterceptingSlot(ItemStackHandler inputItems, int index) {
+ super(inputItems, index);
+ }
+
+ // intercept item on both ends, but only do the post-intercept actions on server side
+ public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) {
+ CurrencyItem mapped = mapToCurrency(newItem);
+ if (mapped != null) {
+ this.putStack(null);
+ if (!client) {
+ TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped);
+ NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private CurrencyItem mapToCurrency(ItemStack newItem) {
+ if (newItem == null) {
+ return null;
+ }
+ return CurrencyItem.fromItemStack(newItem);
+ }
+
+}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java
index 93f1d45..3c48cf9 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java
@@ -4,11 +4,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.stream.Collectors;
-import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.World;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.api.widget.IWidget;
@@ -21,7 +22,6 @@
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widget.SingleChildWidget;
import com.cleanroommc.modularui.widgets.ListWidget;
-import com.cleanroommc.modularui.widgets.PageButton;
import com.cleanroommc.modularui.widgets.PagedWidget;
import com.cleanroommc.modularui.widgets.SlotGroupWidget;
import com.cleanroommc.modularui.widgets.ToggleButton;
@@ -34,8 +34,12 @@
import com.cubefury.vendingmachine.blocks.MTEVendingMachine;
import com.cubefury.vendingmachine.gui.GuiTextures;
import com.cubefury.vendingmachine.gui.WidgetThemes;
+import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync;
+import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.TradeCategory;
import com.cubefury.vendingmachine.trade.TradeDatabase;
+import com.cubefury.vendingmachine.trade.TradeManager;
import com.cubefury.vendingmachine.util.BigItemStack;
import com.cubefury.vendingmachine.util.Translator;
@@ -46,27 +50,38 @@
public class MTEVendingMachineGui extends MTEMultiBlockBaseGui {
private final MTEVendingMachine base;
- private final int height;
public static boolean forceRefresh = false;
private boolean ejectItems = false;
+ private boolean ejectCoins = false;
+ private final Map ejectSingleCoin = new HashMap<>();
private final Map> displayedTrades = new HashMap<>();
private final List tradeCategories = new ArrayList<>();
+ private final List inputSlots = new ArrayList<>();
private PosGuiData guiData;
- private PagedWidget.Controller tabController;
- private SearchBar searchBar;
+ private final PagedWidget.Controller tabController;
+ private final SearchBar searchBar;
+
+ public static String lastSearch = "";
+ public static int lastPage = 0;
+
+ public static final int CUSTOM_UI_HEIGHT = 320;
public static final int ITEMS_PER_ROW = 3;
public static final int ITEM_HEIGHT = 25;
public static final int ITEM_WIDTH = 47;
- private static final int ROW_SEPARATOR_HEIGHT = 5;
+ private static final int COIN_COLUMN_WIDTH = 40;
+ private static final int COIN_COLUMN_ROW_COUNT = 4;
- public MTEVendingMachineGui(MTEVendingMachine base, int height) {
+ public MTEVendingMachineGui(MTEVendingMachine base) {
super(base);
this.base = base;
- this.height = height;
+
+ for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) {
+ ejectSingleCoin.put(type, false);
+ }
this.tradeCategories.add(TradeCategory.ALL);
this.tradeCategories.addAll(TradeDatabase.INSTANCE.getTradeCategories());
@@ -96,7 +111,8 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe
this.guiData = guiData;
registerSyncValues(syncManager);
- ModularPanel panel = new TradeMainPanel("MTEMultiBlockBase", this, guiData, syncManager).size(178, height)
+ ModularPanel panel = new TradeMainPanel("MTEMultiBlockBase", this, guiData, syncManager)
+ .size(178, CUSTOM_UI_HEIGHT)
.padding(4);
panel.child(createCategoryTabs(this.tabController));
Flow mainColumn = new Column().width(170);
@@ -104,6 +120,7 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe
mainColumn.child(createTitleTextStyle(base.getLocalName()))
.child(this.searchBar)
.child(createTradeUI((TradeMainPanel) panel, this.tabController));
+ mainColumn.child(createCoinInventoryRow((TradeMainPanel) panel));
}
mainColumn.child(createInventoryRow(panel, syncManager));
panel.child(mainColumn);
@@ -114,6 +131,13 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe
return panel;
}
+ public void restorePreviousSettings() {
+ if (this.tabController.isInitialised()) {
+ this.tabController.setPage(lastPage);
+ }
+ this.searchBar.setText(lastSearch);
+ }
+
public IWidget createCategoryTabs(PagedWidget.Controller tabController) {
Flow tabColumn = new Column().width(40)
.height(100)
@@ -124,7 +148,7 @@ public IWidget createCategoryTabs(PagedWidget.Controller tabController) {
for (int i = 0; i < this.tradeCategories.size(); i++) {
int index = i;
tabColumn.child(
- new PageButton(i, tabController).tab(GuiTextures.TAB_LEFT, -1)
+ new VendingPageButton(i, tabController).tab(GuiTextures.TAB_LEFT, -1)
.overlay(
this.tradeCategories.get(i)
.getTexture()
@@ -166,51 +190,63 @@ private SearchBar createSearchBar() {
.height(10);
}
- private void ejectItems() {
- if (!this.guiData.isClient()) {
- if (base.getBaseMetaTileEntity() == null) {
- VendingMachine.LOG.info("Unable to eject items as the base MTE for the Vending Machine was null.");
- } else {
- World world = base.getBaseMetaTileEntity()
- .getWorld();
- int posX = base.getBaseMetaTileEntity()
- .getXCoord();
- int posY = base.getBaseMetaTileEntity()
- .getYCoord();
- int posZ = base.getBaseMetaTileEntity()
- .getZCoord();
- int offsetX = base.getExtendedFacing()
- .getDirection().offsetX;
- int offsetY = base.getExtendedFacing()
- .getDirection().offsetY;
- int offsetZ = base.getExtendedFacing()
- .getDirection().offsetZ;
- for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) {
- ItemStack stack = base.inputItems.getStackInSlot(i);
- if (stack != null) {
- ItemStack extracted = base.inputItems.extractItem(i, stack.stackSize, false);
- if (extracted == null) { // if somehow it got pulled out already
- continue;
- }
- final EntityItem itemEntity = new EntityItem(
- world,
- posX + offsetX * 0.5,
- posY + offsetY * 0.5,
- posZ + offsetZ * 0.5,
- new ItemStack(extracted.getItem(), extracted.stackSize, extracted.getItemDamage()));
- if (extracted.hasTagCompound()) {
- itemEntity.getEntityItem()
- .setTagCompound(
- (NBTTagCompound) extracted.getTagCompound()
- .copy());
- }
- itemEntity.delayBeforeCanPickup = 0;
- itemEntity.motionX = 0.05f * offsetX;
- itemEntity.motionY = 0.05f * offsetY;
- itemEntity.motionZ = 0.05f * offsetZ;
- world.spawnEntityInWorld(itemEntity);
- }
- }
+ // Eject code is in GUI instead of MTE since the syncers are per-gui instance
+ private void doEjectCoin(CurrencyItem.CurrencyType type) {
+ if (this.guiData.isClient()) {
+ return;
+ }
+ UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser());
+ if (
+ !TradeManager.INSTANCE.playerCurrency.containsKey(currentUser)
+ || !TradeManager.INSTANCE.playerCurrency.get(currentUser)
+ .containsKey(type)
+ ) {
+ this.ejectSingleCoin.put(type, false);
+ return;
+ }
+ for (ItemStack ejectable : new CurrencyItem(
+ type,
+ TradeManager.INSTANCE.playerCurrency.get(currentUser)
+ .get(type)).itemize()) {
+ base.spawnItem(ejectable);
+ }
+ TradeManager.INSTANCE.resetCurrency(currentUser, type);
+ NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser(), type);
+ this.ejectSingleCoin.put(type, false);
+ }
+
+ private void doEjectCoins() {
+ if (this.guiData.isClient()) {
+ return;
+ }
+
+ UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser());
+ if (!TradeManager.INSTANCE.playerCurrency.containsKey(currentUser)) {
+ ejectCoins = false;
+ return;
+ }
+
+ Map coins = TradeManager.INSTANCE.playerCurrency
+ .getOrDefault(currentUser, new HashMap<>());
+ for (Map.Entry entry : coins.entrySet()) {
+ for (ItemStack ejectable : new CurrencyItem(entry.getKey(), entry.getValue()).itemize()) {
+ base.spawnItem(ejectable);
+ }
+ }
+ TradeManager.INSTANCE.resetCurrency(currentUser, null);
+ NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser(), null);
+ ejectCoins = false;
+ }
+
+ private void doEjectItems() {
+ if (this.guiData.isClient()) {
+ return;
+ }
+ for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) {
+ ItemStack stack = base.inputItems.getStackInSlot(i);
+ if (stack != null) {
+ base.inputItems.setStackInSlot(i, null);
+ base.spawnItem(stack.copy());
}
}
ejectItems = false;
@@ -239,7 +275,14 @@ private IWidget createIOColumn(PanelSyncManager syncManager) {
new ToggleButton().overlay(GTGuiTextures.OVERLAY_BUTTON_CYCLIC)
.tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.item_eject")))
.syncHandler("ejectItems")
- .center())
+ .right(6))
+ .child(
+ new ToggleButton().overlay(
+ GuiTextures.EJECT_COINS.asIcon()
+ .size(14))
+ .tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.coin_eject")))
+ .syncHandler("ejectCoins")
+ .left(6))
.top(80)
.height(18))
.child(
@@ -259,11 +302,23 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) {
return SlotGroupWidget.builder()
.matrix("II", "II", "II")
.key('I', index -> {
+ InterceptingSlot slot = new InterceptingSlot(base.inputItems, index);
+ this.inputSlots.add(slot);
return new ItemSlot().slot(
- new ModularSlot(base.inputItems, index).slotGroup("inputSlotGroup")
+ slot.slotGroup("inputSlotGroup")
.changeListener((newItem, onlyAmountChanged, client, init) -> {
- if (guiData.isClient()) {
+ boolean hasCoin = slot.intercept(
+ newItem,
+ client,
+ this.getBase()
+ .getCurrentUser());
+ if (client) {
forceRefresh = true;
+ return;
+ }
+ // server side force refresh
+ if (hasCoin) {
+ this.refreshInputSlots();
}
}));
})
@@ -271,7 +326,6 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) {
}
private SlotGroupWidget createOutputSlots() {
- // we use slot group widget in case we want to increase the number of output slots in the future
return SlotGroupWidget.builder()
.matrix("II", "II")
.key('I', index -> {
@@ -290,15 +344,17 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
.debugName("paged")
.controller(tabController)
.background(GuiTextures.TEXT_FIELD_BACKGROUND)
- .heightRel(0.5f);
+ .height(146);
for (TradeCategory category : this.tradeCategories) {
- ListWidget tradeList = new ListWidget<>().debugName("items").heightRel(1.0f)
+ ListWidget tradeList = new ListWidget<>().debugName("items")
.width(156)
- .margin(1)
+ .top(1)
+ .height(144)
.collapseDisabledChild(true);
+ tradeList.child(new Row().height(2));
// Higher first row top margin
- Flow row = new TradeRow().height(ITEM_HEIGHT).margin(1).marginTop(4);
+ Flow row = new TradeRow().height(ITEM_HEIGHT+2).left(2);
for (int i = 0; i < MTEVendingMachine.MAX_TRADES; i++) {
int index = i;
@@ -316,6 +372,9 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
}
builder.emptyLine();
builder.addLine(IKey.str(Translator.translate("vendingmachine.gui.required_inputs")).style(IKey.DARK_GREEN, IKey.ITALIC));
+ for (CurrencyItem currencyItem: cur.fromCurrency) {
+ builder.addLine(IKey.str(currencyItem.value + " " + currencyItem.type.getLocalizedName()).style(IKey.DARK_GREEN));
+ }
for (BigItemStack fromItem : cur.fromItems) {
builder.addLine(IKey.str(fromItem.stackSize + " " + fromItem.getBaseStack().getDisplayName()).style(IKey.DARK_GREEN));
}
@@ -332,7 +391,7 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
if (i % ITEMS_PER_ROW == ITEMS_PER_ROW - 1) {
tradeList.child(row);
- row = new TradeRow().height(ITEM_HEIGHT).margin(1);
+ row = new TradeRow().height(ITEM_HEIGHT+2).left(2);
}
}
if (row.hasChildren()) {
@@ -348,6 +407,65 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
}
// spotless:on
+ private static String getReadableStringFromCoinAmount(int amount) {
+ if (amount < 10000) {
+ return "" + amount;
+ } else if (amount < 1000000) {
+ return amount / 1000 + "K";
+ } else {
+ return amount / 1000000 + "M";
+ }
+ }
+
+ private IWidget createCoinInventoryRow(TradeMainPanel panel) {
+ Flow parent = new Row() // .background(GuiTextures.TEXT_FIELD_BACKGROUND)
+ .width(162)
+ .height(36)
+ .top(172)
+ .left(3);
+ Flow coinColumn = new Column().width(COIN_COLUMN_WIDTH);
+ int coinCount = 0;
+ Map currentAmounts = TradeManager.INSTANCE.playerCurrency
+ .getOrDefault(NameCache.INSTANCE.getUUIDFromPlayer(getBase().getCurrentUser()), new HashMap<>());
+ for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) {
+ coinColumn.child(
+ new Row().child(
+ new CoinButton(panel, type).overlay(
+ type.texture.asIcon()
+ .size(12))
+ .size(12)
+ .left(0)
+ .syncHandler("ejectCoin_" + type.id)
+ .tooltipDynamic((builder) -> {
+ builder.clearText();
+ builder.addLine(currentAmounts.getOrDefault(type, 0) + " " + type.getLocalizedName());
+ builder.emptyLine();
+ builder.addLine(
+ IKey.str(Translator.translate("vendingmachine.gui.single_coin_type_eject_hint"))
+ .style(IKey.GRAY, IKey.ITALIC));
+ builder.setAutoUpdate(true);
+ }))
+ .child(
+ IKey.dynamic(
+ () -> getReadableStringFromCoinAmount(
+ currentAmounts.get(type) == null ? 0 : currentAmounts.get(type)))
+ .scale(0.8f)
+ .asWidget()
+ .top(3)
+ .left(14)
+ .width(21))
+ .height(14));
+ if (++coinCount % COIN_COLUMN_ROW_COUNT == 0) {
+ parent.child(coinColumn.left(3 + COIN_COLUMN_WIDTH * (coinCount / COIN_COLUMN_ROW_COUNT - 1)));
+ coinColumn = new Column().width(COIN_COLUMN_WIDTH);
+ }
+ }
+ if (coinColumn.hasChildren()) {
+ parent.child(coinColumn.left(3 + COIN_COLUMN_WIDTH * (coinCount / COIN_COLUMN_ROW_COUNT)));
+ }
+ return parent;
+ }
+
// why is the original method private lmao
private IWidget createInventoryRow(ModularPanel panel, PanelSyncManager syncManager) {
return new Row().widthRel(1)
@@ -363,16 +481,33 @@ private IWidget createInventoryRow(ModularPanel panel, PanelSyncManager syncMana
@Override
protected void registerSyncValues(PanelSyncManager syncManager) {
super.registerSyncValues(syncManager);
- syncManager.registerSlotGroup("inputSlotGroup", 7, true);
- syncManager.registerSlotGroup("outputSlotGroup", 1, false);
+ syncManager.registerSlotGroup("inputSlotGroup", 6, true);
+ syncManager.registerSlotGroup("outputSlotGroup", 4, false);
BooleanSyncValue ejectItemsSyncer = new BooleanSyncValue(() -> this.ejectItems, val -> {
this.ejectItems = val;
if (this.ejectItems) {
- ejectItems();
+ doEjectItems();
+ }
+ });
+ BooleanSyncValue ejectCoinsSyncer = new BooleanSyncValue(() -> this.ejectCoins, val -> {
+ this.ejectCoins = val;
+ if (this.ejectCoins) {
+ doEjectCoins();
}
});
syncManager.syncValue("ejectItems", ejectItemsSyncer);
+ syncManager.syncValue("ejectCoins", ejectCoinsSyncer);
+
+ for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) {
+ BooleanSyncValue ejectCoinSyncer = new BooleanSyncValue(() -> this.ejectSingleCoin.get(type), val -> {
+ this.ejectSingleCoin.put(type, val);
+ if (val) {
+ doEjectCoin(type);
+ }
+ });
+ syncManager.syncValue("ejectCoin_" + type.id, ejectCoinSyncer);
+ }
}
public void attemptPurchase(TradeItemDisplay display) {
@@ -391,7 +526,7 @@ public static void resetForceRefresh() {
forceRefresh = false;
}
- public void updateSlots(Map> trades) {
+ public void updateTradeDisplay(Map> trades) {
synchronized (displayedTrades) {
for (Map.Entry> entry : displayedTrades.entrySet()) {
int displayedSize = trades.get(entry.getKey()) == null ? 0
@@ -399,13 +534,13 @@ public void updateSlots(Map> trades) {
.size();
for (int i = 0; i < MTEVendingMachine.MAX_TRADES; i++) {
if (i < displayedSize) {
- displayedTrades.get(entry.getKey())
+ entry.getValue()
.get(i)
.setDisplay(
trades.get(entry.getKey())
.get(i));
} else {
- displayedTrades.get(entry.getKey())
+ entry.getValue()
.get(i)
.setDisplay(null);
}
@@ -414,8 +549,32 @@ public void updateSlots(Map> trades) {
}
}
+ public Map> getTradeDisplayData() {
+ Map> currentData = new HashMap<>();
+ synchronized (displayedTrades) {
+ this.displayedTrades.forEach((k, v) -> {
+ currentData.put(
+ k,
+ v.stream()
+ .map(TradeItemDisplayWidget::getDisplay)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList()));
+ });
+ }
+ return currentData;
+ }
+
public String getSearchBarText() {
return this.searchBar.getText();
}
+ // server-side sync for all input slots
+ // during next tick after any input
+ private void refreshInputSlots() {
+ for (InterceptingSlot slot : this.inputSlots) {
+ slot.getSyncHandler()
+ .forceSyncItem();
+ }
+ }
+
}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java
index a758b07..72de631 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java
@@ -94,6 +94,7 @@ public void onUpdate() {
super.onUpdate();
String curText = getText();
if (!curText.equals(previousText)) {
+ MTEVendingMachineGui.lastSearch = curText;
gui.setForceRefresh();
}
previousText = curText;
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java
index 95548c0..1845e84 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java
@@ -1,21 +1,18 @@
package com.cubefury.vendingmachine.blocks.gui;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraftforge.common.util.Constants;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.util.BigItemStack;
-import com.cubefury.vendingmachine.util.NBTConverter;
import codechicken.nei.api.ItemFilter;
public class TradeItemDisplay {
+ public List fromCurrency;
public List fromItems;
public List toItems;
public ItemStack display;
@@ -28,9 +25,10 @@ public class TradeItemDisplay {
public boolean enabled;
public boolean tradeableNow;
- public TradeItemDisplay(List fromItems, List toItems, ItemStack display, UUID tgID,
- int tradeGroupOrder, String label, long cooldown, String cooldownText, boolean hasCooldown, boolean enabled,
- boolean tradeableNow) {
+ public TradeItemDisplay(List fromCurrency, List fromItems, List toItems,
+ ItemStack display, UUID tgID, int tradeGroupOrder, String label, long cooldown, String cooldownText,
+ boolean hasCooldown, boolean enabled, boolean tradeableNow) {
+ this.fromCurrency = fromCurrency;
this.fromItems = fromItems;
this.toItems = toItems;
this.display = display;
@@ -44,74 +42,6 @@ public TradeItemDisplay(List fromItems, List toItems
this.tradeableNow = tradeableNow;
}
- public static TradeItemDisplay readFromNBT(NBTTagCompound nbt) {
- List newFromItems = new ArrayList<>();
- NBTTagList fromItemsList = nbt.getTagList("fromItems", Constants.NBT.TAG_COMPOUND);
- for (int i = 0; i < fromItemsList.tagCount(); i++) {
- newFromItems.add(BigItemStack.loadItemStackFromNBT(fromItemsList.getCompoundTagAt(i)));
- }
- List newToItems = new ArrayList<>();
- NBTTagList toItemsList = nbt.getTagList("toItems", Constants.NBT.TAG_COMPOUND);
- for (int i = 0; i < fromItemsList.tagCount(); i++) {
- newToItems.add(BigItemStack.loadItemStackFromNBT(toItemsList.getCompoundTagAt(i)));
- }
- return new TradeItemDisplay(
- newFromItems,
- newToItems,
- ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("display")),
- NBTConverter.UuidValueType.TRADEGROUP.readId(nbt),
- nbt.getInteger("tradeGroupOrder"),
- nbt.getString("label"),
- nbt.getLong("cooldown"),
- nbt.getString("cooldownText"),
- nbt.getBoolean("hasCooldown"),
- nbt.getBoolean("enabled"),
- nbt.getBoolean("tradeableNow"));
- }
-
- public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
- NBTTagList fromItemsNBT = new NBTTagList();
- for (BigItemStack bis : this.fromItems) {
- fromItemsNBT.appendTag(bis.writeToNBT(new NBTTagCompound()));
- }
- nbt.setTag("fromItems", fromItemsNBT);
- NBTTagList toItemsNBT = new NBTTagList();
- for (BigItemStack bis : this.toItems) {
- toItemsNBT.appendTag(bis.writeToNBT(new NBTTagCompound()));
- }
- nbt.setTag("toItems", toItemsNBT);
- nbt.setTag("display", this.display.writeToNBT(new NBTTagCompound()));
- NBTConverter.UuidValueType.TRADEGROUP.writeId(this.tgID, nbt);
- nbt.setInteger("tradeGroupOrder", this.tradeGroupOrder);
- nbt.setString("label", this.label);
- nbt.setLong("cooldown", this.cooldown);
- nbt.setString("cooldownText", this.cooldownText);
- nbt.setBoolean("hasCooldown", this.hasCooldown);
- nbt.setBoolean("enabled", this.enabled);
- nbt.setBoolean("tradeableNow", this.tradeableNow);
-
- return nbt;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof TradeItemDisplay)) {
- return false;
- }
- TradeItemDisplay other = (TradeItemDisplay) obj;
- return this.fromItems.equals(other.fromItems) && this.toItems.equals(other.toItems)
- && ItemStack.areItemStacksEqual(this.display, other.display)
- && ItemStack.areItemStackTagsEqual(this.display, other.display)
- && this.tgID == other.tgID
- && this.tradeGroupOrder == other.tradeGroupOrder
- && this.label.equals(other.label)
- && this.cooldown == other.cooldown
- && this.cooldownText.equals(other.cooldownText)
- && this.hasCooldown == other.hasCooldown
- && this.enabled == other.enabled
- && this.tradeableNow == other.tradeableNow;
- }
-
public boolean satisfiesSearch(ItemFilter filter, String searchStringNoCase) {
if (filter == null) {
return this.label.toLowerCase()
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java
index a40be03..65641ef 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java
@@ -63,7 +63,14 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
GuiDraw.drawOutline(1, 1, 45, 23, 0x883CFF00, 2);
}
if (this.display.hasCooldown || !this.display.enabled) {
- GuiDraw.drawRoundedRect(1, 1, 45, 23, 0xBB000000, 1, 1);
+ GuiDraw.drawRoundedRect(
+ 1,
+ 1,
+ MTEVendingMachineGui.ITEM_WIDTH - 2,
+ MTEVendingMachineGui.ITEM_HEIGHT - 2,
+ 0xBB000000,
+ 1,
+ 1);
}
this.overlay(
IKey.str(display.hasCooldown ? this.display.cooldownText : "")
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java
index 9e23077..adbc310 100644
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java
@@ -15,10 +15,13 @@
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
+import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cubefury.vendingmachine.Config;
import com.cubefury.vendingmachine.blocks.MTEVendingMachine;
+import com.cubefury.vendingmachine.network.handlers.NetResetVMUser;
import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.Trade;
import com.cubefury.vendingmachine.trade.TradeCategory;
import com.cubefury.vendingmachine.trade.TradeDatabase;
@@ -67,7 +70,7 @@ public boolean onKeyRelease(char typedChar, int keyCode) {
}
public void updateGui() {
- boolean test = true;
+ boolean test = false;
if (test) {
List testTGW = new ArrayList<>();
for (Map.Entry entry : TradeDatabase.INSTANCE.getTradeGroups()
@@ -75,14 +78,51 @@ public void updateGui() {
testTGW.add(new TradeGroupWrapper(entry.getValue(), -1, true));
}
Map> trades = formatTrades(testTGW);
- gui.updateSlots(trades);
+ gui.updateTradeDisplay(trades);
+ } else if (shiftHeld) {
+ this.updateTradeInformation(gui.getTradeDisplayData());
} else {
Map> trades = formatTrades(
TradeManager.INSTANCE.getTrades(NameCache.INSTANCE.getUUIDFromPlayer(syncManager.getPlayer())));
- gui.updateSlots(trades);
+ gui.updateTradeDisplay(trades);
}
}
+ private void updateTradeInformation(Map> currentData) {
+ Map availableItems = this.guiData.isClient() && this.gui.getBase() != null
+ ? getAvailableItems()
+ : new HashMap<>();
+
+ Map tradeGroups = new HashMap<>();
+ TradeManager.INSTANCE.getTrades(NameCache.INSTANCE.getUUIDFromPlayer(syncManager.getPlayer()))
+ .forEach(
+ (tg) -> {
+ tradeGroups.put(
+ tg.trade()
+ .getId(),
+ tg);
+ });
+ currentData.forEach((k, v) -> {
+ for (TradeItemDisplay tid : v) {
+ TradeGroupWrapper cur = tradeGroups.get(tid.tgID);
+ tid.enabled = cur != null && cur.enabled();
+ tid.hasCooldown = cur.cooldown() > 0;
+ tid.cooldown = cur.cooldown();
+ tid.cooldownText = convertCooldownText(cur.cooldown());
+ tid.tradeableNow = checkItemsSatisfied(
+ cur.trade()
+ .getTrades()
+ .get(tid.tradeGroupOrder).fromItems,
+ availableItems)
+ && checkCurrencySatisfied(
+ cur.trade()
+ .getTrades()
+ .get(tid.tradeGroupOrder).fromCurrency,
+ TradeManager.INSTANCE.playerCurrency.get(NameCache.INSTANCE.getUUIDFromPlayer(this.player)));
+ }
+ });
+ }
+
@Override
public void onUpdate() {
@@ -93,9 +133,15 @@ public void onUpdate() {
if (this.player == null && this.syncManager.isInitialised()) {
this.player = syncManager.getPlayer();
}
- if (gui.forceRefresh || (this.ticksOpen % Config.gui_refresh_interval == 0 && player != null && !shiftHeld)) {
+ if (TradeManager.INSTANCE.hasCurrencyUpdate) {
+ MTEVendingMachineGui.setForceRefresh();
+ }
+ if (
+ MTEVendingMachineGui.forceRefresh
+ || (this.ticksOpen % Config.gui_refresh_interval == 0 && player != null && !shiftHeld)
+ ) {
updateGui();
- gui.resetForceRefresh();
+ MTEVendingMachineGui.resetForceRefresh();
}
this.ticksOpen += 1;
}
@@ -120,6 +166,18 @@ public ItemStack convertToItemStack(BigItemStack stack) {
return display;
}
+ public boolean checkCurrencySatisfied(List currencyItems,
+ Map availableItems) {
+ if (currencyItems == null) {
+ return true;
+ }
+ if (availableItems == null) {
+ return false;
+ }
+ return currencyItems.stream()
+ .allMatch(ci -> availableItems.containsKey(ci.type) && availableItems.get(ci.type) >= ci.value);
+ }
+
public boolean checkItemsSatisfied(List trade, Map availableItems) {
for (BigItemStack bis : trade) {
BigItemStack base = bis.copy();
@@ -146,7 +204,6 @@ public Map getAvailableItems() {
}
public Map> formatTrades(List tradeGroups) {
-
Map availableItems = this.guiData.isClient() && this.gui.getBase() != null
? getAvailableItems()
: new HashMap<>();
@@ -166,6 +223,7 @@ public Map> formatTrades(List> formatTrades(List 0,
tgw.enabled(),
- checkItemsSatisfied(trade.fromItems, availableItems));
+ checkItemsSatisfied(trade.fromItems, availableItems) && checkCurrencySatisfied(
+ trade.fromCurrency,
+ TradeManager.INSTANCE.playerCurrency.get(NameCache.INSTANCE.getUUIDFromPlayer(this.player))));
trades.get(category)
.add(tid);
@@ -245,4 +305,19 @@ private static int getRank(TradeItemDisplay t) {
public void attemptPurchase(TradeItemDisplay display) {
gui.attemptPurchase(display);
}
+
+ @Override
+ public void dispose() {
+ this.gui.getBase()
+ .resetCurrentUser(this.player);
+ // We have to sync reset use manually since dispose() is only run client-side
+ NetResetVMUser.sendReset(this.gui.getBase());
+ super.dispose();
+ }
+
+ @Override
+ public void onOpen(ModularScreen screen) {
+ super.onOpen(screen);
+ gui.restorePreviousSettings();
+ }
}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java
deleted file mode 100644
index 97d0f77..0000000
--- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.cubefury.vendingmachine.blocks.gui;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Queue;
-
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.PacketBuffer;
-
-import org.jetbrains.annotations.NotNull;
-
-import com.cleanroommc.modularui.utils.serialization.IByteBufAdapter;
-
-public class TradeQueueAdapter implements IByteBufAdapter> {
-
- @Override
- public Queue deserialize(PacketBuffer buffer) throws IOException {
- int size = buffer.readVarIntFromBuffer();
- Queue queue = new LinkedList<>();
-
- for (int i = 0; i < size; i++) {
- NBTTagCompound tag = buffer.readNBTTagCompoundFromBuffer();
- if (tag != null) {
- queue.add(TradeItemDisplay.readFromNBT(tag));
- }
- }
- return queue;
- }
-
- @Override
- public void serialize(PacketBuffer buffer, Queue queue) throws IOException {
- buffer.writeVarIntToBuffer(queue.size());
- for (TradeItemDisplay item : queue) {
- buffer.writeNBTTagCompoundToBuffer(item.writeToNBT(new NBTTagCompound()));
- }
- }
-
- @Override
- public boolean areEqual(@NotNull Queue t1, @NotNull Queue t2) {
- if (t1.size() != t2.size()) {
- return false;
- }
-
- Iterator it1 = t1.iterator();
- Iterator it2 = t2.iterator();
-
- while (it1.hasNext() && it2.hasNext()) {
- TradeItemDisplay d1 = it1.next();
- TradeItemDisplay d2 = it2.next();
- if (!d1.equals(d2)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java
new file mode 100644
index 0000000..100eea1
--- /dev/null
+++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java
@@ -0,0 +1,23 @@
+package com.cubefury.vendingmachine.blocks.gui;
+
+import org.jetbrains.annotations.NotNull;
+
+import com.cleanroommc.modularui.widgets.PageButton;
+import com.cleanroommc.modularui.widgets.PagedWidget;
+
+public class VendingPageButton extends PageButton {
+
+ private final int index;
+
+ public VendingPageButton(int index, PagedWidget.Controller controller) {
+ super(index, controller);
+
+ this.index = index;
+ }
+
+ @Override
+ public @NotNull Result onMousePressed(int mouseButton) {
+ MTEVendingMachineGui.lastPage = this.index;
+ return super.onMousePressed(mouseButton);
+ }
+}
diff --git a/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java b/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java
index 5892355..8ee5829 100644
--- a/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java
+++ b/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java
@@ -71,6 +71,12 @@ public final class GuiTextures {
.name("background_output")
.build();
+ public static final UITexture EJECT_COINS = UITexture.builder()
+ .location(VendingMachine.MODID, "gui/overlay/coinEject")
+ .imageSize(16, 16)
+ .name("coin_eject")
+ .build();
+
public static final TabTexture TAB_LEFT = TabTexture
.of(UITexture.fullImage(VendingMachine.MODID, "gui/tabs_left", true), GuiAxis.X, false, 32, 28, 4);
}
diff --git a/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java b/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java
index c5c2dbd..06febcf 100644
--- a/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java
+++ b/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java
@@ -1,17 +1,26 @@
package com.cubefury.vendingmachine.handlers;
import java.util.ArrayDeque;
+import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
+import javax.annotation.Nonnull;
+
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.event.entity.living.LivingDeathEvent;
import org.apache.commons.lang3.Validate;
+import com.cleanroommc.modularui.factory.PosGuiData;
+import com.cleanroommc.modularui.screen.ModularContainer;
import com.cubefury.vendingmachine.VendingMachine;
+import com.cubefury.vendingmachine.blocks.MTEVendingMachine;
import com.cubefury.vendingmachine.events.MarkDirtyDbEvent;
import com.cubefury.vendingmachine.events.MarkDirtyNamesEvent;
import com.cubefury.vendingmachine.network.handlers.NetBulkSync;
@@ -24,6 +33,7 @@
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class EventHandler {
@@ -72,6 +82,18 @@ public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
UUID playerId = NameCache.INSTANCE.getUUIDFromPlayer(mpPlayer);
}
+ @SubscribeEvent
+ public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
+ terminateVendingSession(event.player);
+ }
+
+ @SubscribeEvent
+ public void onPlayerDeath(LivingDeathEvent event) {
+ if (event.entityLiving instanceof EntityPlayer) {
+ terminateVendingSession((EntityPlayer) event.entityLiving);
+ }
+ }
+
@SuppressWarnings("UnstableApiUsage")
public static ListenableFuture scheduleServerTask(Callable task) {
Validate.notNull(task);
@@ -123,4 +145,28 @@ public void onServerTick(TickEvent.ServerTickEvent event) {
}
}
+ private void terminateVendingSession(@Nonnull EntityPlayer player) {
+ VendingMachine.LOG.info("terminating session for {}", player);
+ if (VendingMachine.proxy.isClient()) {
+ return;
+ }
+ if (
+ !(player.openContainer instanceof ModularContainer
+ && ((ModularContainer) player.openContainer).getGuiData() instanceof PosGuiData)
+ ) {
+ return;
+ }
+ TileEntity te = ((PosGuiData) ((ModularContainer) player.openContainer).getGuiData()).getTileEntity();
+
+ if (
+ te instanceof IGregTechTileEntity
+ && ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MTEVendingMachine
+ ) {
+ VendingMachine.LOG.info("found VM MTE terminating session for {}", player);
+ ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetCurrentUser(player);
+ SaveLoadHandler.INSTANCE
+ .writeTradeState(Collections.singleton(NameCache.INSTANCE.getUUIDFromPlayer(player)));
+ }
+ }
+
}
diff --git a/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java b/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java
index a6b621f..78dfc7a 100644
--- a/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java
+++ b/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java
@@ -1,5 +1,6 @@
package com.cubefury.vendingmachine.integration.betterquesting.gui;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.Trade;
import betterquesting.api.utils.BigItemStack;
@@ -29,6 +30,7 @@ public void initPanel() {
super.initPanel();
int x_offset = 0;
+
for (int i = 0; i < trade.fromItems.size(); i++) {
BigItemStack stack = trade.fromItems.get(i)
.toBQBigItemStack();
@@ -40,6 +42,17 @@ public void initPanel() {
x_offset += 20;
}
+ for (int i = 0; i < trade.fromCurrency.size(); i++) {
+ CurrencyItem currencyItem = trade.fromCurrency.get(i);
+ BigItemStack stack = new BigItemStack(currencyItem.getItemRepresentation());
+ GuiRectangle rectangle = new GuiRectangle(x_offset, 0, 18, 18, 0);
+ PanelItemSlot is = PanelItemSlotBuilder.forValue(stack, rectangle)
+ .showCount(true)
+ .build();
+ this.addPanel(is);
+ x_offset += 20;
+ }
+
// +1px buffer on each side to regularize slightly smaller icon size (16px vs 18px of items)
this.addPanel(
new PanelGeneric(
diff --git a/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java b/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java
index 6b5477e..3e5f78a 100644
--- a/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java
+++ b/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java
@@ -25,6 +25,7 @@
import com.cubefury.vendingmachine.integration.betterquesting.BqAdapter;
import com.cubefury.vendingmachine.integration.betterquesting.BqCondition;
import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.Trade;
import com.cubefury.vendingmachine.util.BigItemStack;
import com.cubefury.vendingmachine.util.Translator;
@@ -330,6 +331,14 @@ private void loadInputs(Trade trade) {
inputs.add(new PositionedStack(extractStacks(stack), x, y));
index++;
}
+ for (CurrencyItem ci : trade.fromCurrency) {
+ if (index >= GRID_COUNT) {
+ break;
+ }
+ int x = xOffset + index * SLOT_SIZE;
+ inputs.add(new PositionedStack(ci.getItemRepresentation(), x, y));
+ index++;
+ }
}
private void loadOutputs(Trade trade) {
diff --git a/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java b/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java
index 7237519..6876caf 100644
--- a/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java
+++ b/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java
@@ -15,6 +15,7 @@
import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync;
import com.cubefury.vendingmachine.network.handlers.NetBulkSync;
import com.cubefury.vendingmachine.network.handlers.NetNameSync;
+import com.cubefury.vendingmachine.network.handlers.NetResetVMUser;
import com.cubefury.vendingmachine.network.handlers.NetSatisfiedQuestSync;
import com.cubefury.vendingmachine.network.handlers.NetTradeDbSync;
import com.cubefury.vendingmachine.network.handlers.NetTradeRequestSync;
@@ -34,8 +35,8 @@ public void init() {
NetTradeRequestSync.registerHandler();
NetSatisfiedQuestSync.registerHandler();
NetNameSync.registerHandler();
-
NetBulkSync.registerHandler();
+ NetResetVMUser.registerHandler();
}
@Override
diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java
index 2a80342..26746fa 100644
--- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java
+++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java
@@ -52,6 +52,7 @@ public static void sendSync(@Nonnull EntityPlayerMP player) {
NetNameSync.sendNames(new EntityPlayerMP[] { player }, new UUID[] { playerId }, null);
NetTradeDbSync.sendDatabase(player, false);
+ NetTradeStateSync.sendTradeState(player, false);
}
private static void onServer(Tuple2 message) {
diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java
new file mode 100644
index 0000000..b47ec77
--- /dev/null
+++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java
@@ -0,0 +1,65 @@
+package com.cubefury.vendingmachine.network.handlers;
+
+import java.util.Collections;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+
+import com.cubefury.vendingmachine.VendingMachine;
+import com.cubefury.vendingmachine.api.network.UnserializedPacket;
+import com.cubefury.vendingmachine.api.util.Tuple2;
+import com.cubefury.vendingmachine.blocks.MTEVendingMachine;
+import com.cubefury.vendingmachine.handlers.SaveLoadHandler;
+import com.cubefury.vendingmachine.network.PacketSender;
+import com.cubefury.vendingmachine.network.PacketTypeRegistry;
+import com.cubefury.vendingmachine.storage.NameCache;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public class NetResetVMUser {
+
+ private static final ResourceLocation ID_NAME = new ResourceLocation("vendingmachine:reset_vmuser");
+
+ public static void registerHandler() {
+ PacketTypeRegistry.INSTANCE.registerServerHandler(ID_NAME, NetResetVMUser::onServer);
+ }
+
+ public static void sendReset(MTEVendingMachine base) {
+ IGregTechTileEntity baseTile = base.getBaseMetaTileEntity();
+ if (baseTile == null) {
+ VendingMachine.LOG.warn("attempting to reset user for null base MTE");
+ return;
+ }
+ NBTTagCompound payload = new NBTTagCompound();
+ payload.setInteger("dim", baseTile.getWorld().provider.dimensionId);
+ payload.setInteger("x", baseTile.getXCoord());
+ payload.setInteger("y", baseTile.getYCoord());
+ payload.setInteger("z", baseTile.getZCoord());
+ PacketSender.INSTANCE.sendToServer(new UnserializedPacket(ID_NAME, payload));
+ }
+
+ public static void onServer(Tuple2 message) {
+ World world = DimensionManager.getWorld(
+ message.first()
+ .getInteger("dim"));
+ TileEntity te = world.getTileEntity(
+ message.first()
+ .getInteger("x"),
+ message.first()
+ .getInteger("y"),
+ message.first()
+ .getInteger("z"));
+ if (
+ te instanceof IGregTechTileEntity
+ && ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MTEVendingMachine
+ ) {
+ ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetCurrentUser(message.second());
+ }
+ SaveLoadHandler.INSTANCE
+ .writeTradeState(Collections.singleton(NameCache.INSTANCE.getUUIDFromPlayer(message.second())));
+ }
+}
diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java
index 7c3d619..c6cd086 100644
--- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java
+++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java
@@ -2,6 +2,7 @@
import java.util.UUID;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
@@ -15,7 +16,9 @@
import com.cubefury.vendingmachine.network.PacketSender;
import com.cubefury.vendingmachine.network.PacketTypeRegistry;
import com.cubefury.vendingmachine.storage.NameCache;
+import com.cubefury.vendingmachine.trade.CurrencyItem;
import com.cubefury.vendingmachine.trade.TradeDatabase;
+import com.cubefury.vendingmachine.trade.TradeManager;
import com.cubefury.vendingmachine.util.NBTConverter;
import cpw.mods.fml.relauncher.Side;
@@ -23,6 +26,8 @@
public class NetTradeStateSync {
+ // We can send tradestate + currency data, or just currency data
+ // The latter is far more lightweight, and will likely see higher traffic volume
private static final ResourceLocation ID_NAME = new ResourceLocation("vendingmachine:tradestate_sync");
public static void registerHandler() {
@@ -34,36 +39,49 @@ public static void registerHandler() {
}
// server side code for sending tradegroup data when player opens gui
- public static void sendTradeState(@Nullable EntityPlayerMP player, boolean merge) {
+ public static void sendTradeState(@Nonnull EntityPlayerMP player, boolean merge) {
TradeDatabase db = TradeDatabase.INSTANCE;
UUID playerId = NameCache.INSTANCE.getUUIDFromPlayer(player);
NBTTagCompound payload = new NBTTagCompound();
+ payload.setString("dataType", "tradeState");
payload.setBoolean("merge", merge);
NBTConverter.UuidValueType.PLAYER.writeId(playerId, payload);
db.writeTradeStateToNBT(new NBTTagCompound(), playerId);
- if (player == null) { // shouldn't happen, since we're only updating one player
- PacketSender.INSTANCE.sendToAll(new UnserializedPacket(ID_NAME, payload));
- } else {
- PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player);
+ PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player);
+ }
+
+ public static void sendPlayerCurrency(@Nonnull EntityPlayerMP player, CurrencyItem currencyItem) {
+ NBTTagCompound payload = new NBTTagCompound();
+ payload.setString("dataType", "currency_add");
+ currencyItem.writeToNBT(payload);
+
+ PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player);
+ }
+
+ public static void resetPlayerCurrency(@Nonnull EntityPlayerMP player, @Nullable CurrencyItem.CurrencyType type) {
+ NBTTagCompound payload = new NBTTagCompound();
+ payload.setString("dataType", "currency_reset");
+ if (type != null) {
+ payload.setString("type", type.id);
}
+ PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player);
}
@SideOnly(Side.CLIENT)
public static void requestSync() {
NBTTagCompound payload = new NBTTagCompound();
- payload.setString("requestType", "getTrades");
+ payload.setString("requestType", "getTradeState");
PacketSender.INSTANCE.sendToServer(new UnserializedPacket(ID_NAME, payload));
}
public static void onServer(Tuple2 message) {
- TradeDatabase db = TradeDatabase.INSTANCE;
String requestType = message.first()
.getString("requestType");
- if (requestType.equals("getTrades")) {
+ if (requestType.equals("getTradeState")) {
sendTradeState(message.second(), false);
} else {
VendingMachine.LOG.warn("Unknown trade state sync request type received: {}", requestType);
@@ -81,8 +99,22 @@ public static void onClient(NBTTagCompound message) {
) {
return;
}
- TradeDatabase db = TradeDatabase.INSTANCE;
+ String dataType = message.getString("dataType");
UUID player = NBTConverter.UuidValueType.PLAYER.readId(message);
- db.populateTradeStateFromNBT(message, player, message.getBoolean("merge"));
+ switch (dataType) {
+ case "tradeState" -> {
+ boolean merge = message.getBoolean("merge");
+ TradeDatabase.INSTANCE.populateTradeStateFromNBT(message, player, merge);
+ }
+ case "currency_add" -> {
+ CurrencyItem currencyItem = CurrencyItem.fromNBT(message.getCompoundTag("currencyItem"));
+
+ TradeManager.INSTANCE.addCurrency(player, currencyItem);
+ }
+ case "currency_reset" -> TradeManager.INSTANCE.resetCurrency(
+ player,
+ message.hasKey("type") ? CurrencyItem.CurrencyType.getTypeFromId(message.getString("type")) : null);
+ default -> VendingMachine.LOG.warn("Unknown trade state sync data received: {}", dataType);
+ }
}
}
diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java
new file mode 100644
index 0000000..a0535af
--- /dev/null
+++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java
@@ -0,0 +1,134 @@
+package com.cubefury.vendingmachine.trade;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+import com.cleanroommc.modularui.drawable.UITexture;
+import com.cubefury.vendingmachine.VendingMachine;
+import com.cubefury.vendingmachine.util.Translator;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class CurrencyItem {
+
+ public CurrencyType type;
+ public int value;
+ private static final Map typeMap = new HashMap<>();
+ private static final String[] coinSuffixes = new String[] { "IV", "III", "II", "I", "" };
+ private static final int[] coinValues = new int[] { 10000, 1000, 100, 10, 1 };
+
+ public static CurrencyItem fromNBT(NBTTagCompound nbt) {
+ CurrencyType type = CurrencyType.getTypeFromId(nbt.getString("type"));
+ if (type == null) {
+ return null;
+ }
+ return new CurrencyItem(type, nbt.getInteger("value"));
+ }
+
+ public NBTTagCompound writeToNBT(NBTTagCompound payload) {
+ payload.setString("type", this.type.id);
+ payload.setInteger("value", this.value);
+ return payload;
+ }
+
+ public List itemize() {
+ List outputs = new ArrayList<>();
+ if (this.type == null || this.value <= 0) {
+ return outputs;
+ }
+ for (int i = 0; i < coinValues.length; i++) {
+ while (this.value > coinValues[i]) {
+ Item outputItem = (Item) Item.itemRegistry.getObject(this.type.itemPrefix + coinSuffixes[i]);
+ int stackSize = Math.min(this.value / coinValues[i], outputItem.getItemStackLimit());
+ outputs.add(new ItemStack(outputItem, stackSize));
+ this.value -= stackSize * coinValues[i];
+ }
+ }
+ return outputs;
+ }
+
+ public ItemStack getItemRepresentation() {
+ Item outputItem = (Item) Item.itemRegistry.getObject(this.type.itemPrefix);
+ return new ItemStack(outputItem, value);
+ }
+
+ public enum CurrencyType {
+
+ ADVENTURE("adventure", "dreamcraft:item.CoinAdventure", "gui/icons/itemCoinAdventure.png"),
+ BEES("bees", "dreamcraft:item.CoinBees", "gui/icons/itemCoinBees.png"),
+ BLOOD("blood", "dreamcraft:item.CoinBlood", "gui/icons/itemCoinBlood.png"),
+ CHEMIST("chemist", "dreamcraft:item.CoinChemist", "gui/icons/itemCoinChemist.png"),
+ COOK("cook", "dreamcraft:item.CoinCook", "gui/icons/itemCoinCook.png"),
+ DARK_WIZARD("darkWizard", "dreamcraft:item.CoinDarkWizard", "gui/icons/itemCoinDarkWizard.png"),
+ FARMER("farmer", "dreamcraft:item.CoinFarmer", "gui/icons/itemCoinFarmer.png"),
+ FLOWER("flower", "dreamcraft:item.CoinFlower", "gui/icons/itemCoinFlower.png"),
+ FORESTRY("forestry", "dreamcraft:item.CoinForestry", "gui/icons/itemCoinForestry.png"),
+ SMITH("smith", "dreamcraft:item.CoinSmith", "gui/icons/itemCoinSmith.png"),
+ SPACE("space", "dreamcraft:item.CoinSpace", "gui/icons/itemCoinSpace.png"),
+ SURVIVOR("survivor", "dreamcraft:item.CoinSurvivor", "gui/icons/itemCoinSurvivor.png"),
+ TECHNICIAN("technician", "dreamcraft:item.CoinTechnician", "gui/icons/itemCoinTechnician.png"),
+ WITCH("witch", "dreamcraft:item.CoinWitch", "gui/icons/itemCoinWitch.png"),
+ // comment before semicolon to reduce merge conflicts
+ ;
+
+ public final String id;
+ public final String itemPrefix;
+ public final UITexture texture;
+
+ CurrencyType(String id, String itemPrefix, String texture) {
+ this.id = id;
+ this.itemPrefix = itemPrefix;
+ this.texture = UITexture.builder()
+ .location(VendingMachine.MODID, texture)
+ .imageSize(32, 32)
+ .name("VM_UI_Coin_" + id)
+ .build();
+
+ typeMap.put(this.id, this);
+ }
+
+ public static CurrencyType getTypeFromId(String type) {
+ return typeMap.get(type);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public String getLocalizedName() {
+ return Translator.translate("vendingmachine.coin." + this.id);
+ }
+ }
+
+ public CurrencyItem(CurrencyType type, int value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public static CurrencyItem fromItemStack(ItemStack newItem) {
+ String itemName = Item.itemRegistry.getNameForObject(newItem.getItem());
+ for (CurrencyType type : CurrencyType.values()) {
+ if (itemName.startsWith(type.itemPrefix)) {
+ int currencyValue = mapSuffixToValue(itemName.substring(type.itemPrefix.length()));
+ if (currencyValue < 0) {
+ return null;
+ }
+ return new CurrencyItem(type, currencyValue * newItem.stackSize);
+ }
+ }
+ return null;
+ }
+
+ private static int mapSuffixToValue(String suffix) {
+ for (int i = 0; i < coinSuffixes.length; i++) {
+ if (suffix.equals(coinSuffixes[i])) {
+ return coinValues[i];
+ }
+ }
+ return -1;
+ }
+}
diff --git a/src/main/java/com/cubefury/vendingmachine/trade/Trade.java b/src/main/java/com/cubefury/vendingmachine/trade/Trade.java
index b0c2d51..a0f9a7c 100644
--- a/src/main/java/com/cubefury/vendingmachine/trade/Trade.java
+++ b/src/main/java/com/cubefury/vendingmachine/trade/Trade.java
@@ -20,30 +20,51 @@
public class Trade {
+ public final List fromCurrency = new ArrayList<>();
public final List fromItems = new ArrayList<>();
public final List toItems = new ArrayList<>();
public BigItemStack displayItem = new BigItemStack(ItemPlaceholder.placeholder);
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
nbt.setTag("displayItem", displayItem.writeToNBT(new NBTTagCompound()));
- NBTTagList fromItemsArray = new NBTTagList();
- for (BigItemStack stack : this.fromItems) {
- fromItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound()));
+
+ if (!this.fromCurrency.isEmpty()) {
+ NBTTagList fromCurrencyArray = new NBTTagList();
+ for (CurrencyItem ci : this.fromCurrency) {
+ fromCurrencyArray.appendTag(ci.writeToNBT(new NBTTagCompound()));
+ }
+ nbt.setTag("fromCurrency", fromCurrencyArray);
+ }
+
+ if (!this.fromItems.isEmpty()) {
+ NBTTagList fromItemsArray = new NBTTagList();
+ for (BigItemStack stack : this.fromItems) {
+ fromItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound()));
+ }
+ nbt.setTag("fromItems", fromItemsArray);
}
- nbt.setTag("fromItems", fromItemsArray);
- NBTTagList toItemsArray = new NBTTagList();
- for (BigItemStack stack : this.toItems) {
- toItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound()));
+ if (!this.toItems.isEmpty()) {
+ NBTTagList toItemsArray = new NBTTagList();
+ for (BigItemStack stack : this.toItems) {
+ toItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound()));
+ }
+ nbt.setTag("toItems", toItemsArray);
}
- nbt.setTag("toItems", toItemsArray);
return nbt;
}
public void readFromNBT(NBTTagCompound nbt) {
+ fromCurrency.clear();
fromItems.clear();
toItems.clear();
+
+ NBTTagList currencyList = nbt.getTagList("fromCurrency", Constants.NBT.TAG_COMPOUND);
+ for (int i = 0; i < currencyList.tagCount(); i++) {
+ fromCurrency.add(CurrencyItem.fromNBT(currencyList.getCompoundTagAt(i)));
+ }
+
NBTTagList fromList = nbt.getTagList("fromItems", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < fromList.tagCount(); i++) {
fromItems.add(JsonHelper.JsonToItemStack(fromList.getCompoundTagAt(i)));
diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java
index 71007ae..a6e669a 100644
--- a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java
+++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java
@@ -85,7 +85,7 @@ public void readFromNBT(NBTTagCompound nbt, boolean merge) {
TradeGroup tg = new TradeGroup();
newMetadataCount += tg.readFromNBT(trades.getCompoundTagAt(i)) ? 1 : 0;
if (tradeGroups.containsKey(tg.getId())) {
- VendingMachine.LOG.warn("Multiple trade groups with id {} exist in the file!", tg);
+ VendingMachine.LOG.error("Multiple trade groups with id {} exist in the file!", tg);
continue;
}
tradeCategories.computeIfAbsent(tg.getCategory(), k -> new HashSet<>());
@@ -103,8 +103,7 @@ public void readFromNBT(NBTTagCompound nbt, boolean merge) {
}
TradeManager.INSTANCE.recomputeAvailableTrades(null);
- VendingMachine.LOG
- .info("Loaded {} trade groups containing {} trade groups.", getTradeGroupCount(), getTradeCount());
+ VendingMachine.LOG.info("Loaded {} trade groups containing {} trades.", getTradeGroupCount(), getTradeCount());
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
@@ -129,13 +128,11 @@ public void populateTradeStateFromNBT(NBTTagCompound nbt, UUID player, boolean m
TradeHistory th = new TradeHistory(state.getLong("lastTrade"), state.getInteger("tradeCount"));
tg.setTradeState(player, th);
}
+ TradeManager.INSTANCE.populateCurrencyFromNBT(nbt, player, merge);
}
public NBTTagCompound writeTradeStateToNBT(NBTTagCompound nbt, UUID player) {
NBTTagList tradeStateList = new NBTTagList();
- // This is not very efficient and can take a while to run if there are many trade groups.
- // An alternative is to maintain two copies of this data, one indexing by tradegroup and
- // another indexing by player uuid. Let's do that if it proves to be too slow.
for (Map.Entry entry : tradeGroups.entrySet()) {
TradeHistory history = entry.getValue()
.getTradeState(player);
@@ -148,11 +145,11 @@ public NBTTagCompound writeTradeStateToNBT(NBTTagCompound nbt, UUID player) {
}
}
nbt.setTag("tradeState", tradeStateList);
+ nbt.setTag("playerCurrency", TradeManager.INSTANCE.writeCurrencyToNBT(player));
return nbt;
}
@SideOnly(Side.CLIENT)
- @Optional.Method(modid = "NotEnoughItems")
public void refreshNeiCache() {
NeiRecipeCache.refreshCache();
}
diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java
index 77137a3..8dda1bb 100644
--- a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java
+++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java
@@ -10,7 +10,11 @@
import javax.annotation.Nonnull;
-import com.cubefury.vendingmachine.util.BigItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.common.util.Constants;
+
+import com.cubefury.vendingmachine.VendingMachine;
// This is a cache of available trades, maintained server-side
// so we don't have to recompute what trades are available every time we send it
@@ -20,11 +24,14 @@ public class TradeManager {
private final Map> availableTrades = new HashMap<>();
- private final Map> pendingOutputs = new HashMap<>();
+ public final Map> playerCurrency = new HashMap<>();
- private TradeManager() {}
+ // For writeback to file in original format, to prevent data loss
+ private final Map> invalidCurrency = new HashMap<>();
- public void init() {}
+ public boolean hasCurrencyUpdate = false;
+
+ private TradeManager() {}
public void addTradeGroup(UUID player, UUID tg) {
synchronized (availableTrades) {
@@ -87,14 +94,6 @@ public void recomputeAvailableTrades(UUID player) {
}
}
- public void addPending(UUID player, List pending) {
- if (!pendingOutputs.containsKey(player) || pendingOutputs.get(player) == null) {
- pendingOutputs.put(player, new ArrayList<>());
- }
- pendingOutputs.get(player)
- .addAll(pending);
- }
-
public List getTrades(UUID player) {
long currentTimestamp = System.currentTimeMillis();
synchronized (availableTrades) {
@@ -122,4 +121,81 @@ public List getTrades(UUID player) {
return tradeList;
}
}
+
+ public void populateCurrencyFromNBT(NBTTagCompound nbt, UUID player, boolean merge) {
+ NBTTagList tagList = nbt.getTagList("playerCurrency", Constants.NBT.TAG_COMPOUND);
+ if (!merge) {
+ this.playerCurrency.clear();
+ this.invalidCurrency.clear();
+ }
+ this.playerCurrency.computeIfAbsent(player, k -> new HashMap<>());
+ for (int i = 0; i < tagList.tagCount(); i++) {
+ NBTTagCompound currencyEntry = tagList.getCompoundTagAt(i);
+ CurrencyItem.CurrencyType type = CurrencyItem.CurrencyType
+ .getTypeFromId(currencyEntry.getString("currency"));
+ if (type == null) {
+ VendingMachine.LOG.warn("Unknown currency type found: {}", currencyEntry.getString("currency"));
+ this.invalidCurrency.computeIfAbsent(player, k -> new ArrayList<>());
+ this.invalidCurrency.get(player)
+ .add(currencyEntry);
+ continue;
+ }
+ int amount = currencyEntry.getInteger("amount");
+ this.playerCurrency.get(player)
+ .computeIfAbsent(type, k -> 0);
+ this.playerCurrency.get(player)
+ .put(
+ type,
+ amount + (merge ? this.playerCurrency.get(player)
+ .get(type) : 0));
+ }
+ this.hasCurrencyUpdate = true;
+ }
+
+ public NBTTagList writeCurrencyToNBT(UUID player) {
+ NBTTagList nbt = new NBTTagList();
+ if (this.playerCurrency.get(player) == null) {
+ return nbt;
+ }
+ for (Map.Entry entry : this.playerCurrency.get(player)
+ .entrySet()) {
+ NBTTagCompound currencyEntry = new NBTTagCompound();
+ currencyEntry.setString("currency", entry.getKey().id);
+ currencyEntry.setInteger("amount", entry.getValue());
+ nbt.appendTag(currencyEntry);
+ }
+
+ if (this.invalidCurrency.get(player) != null) {
+ for (NBTTagCompound tag : this.invalidCurrency.get(player)) {
+ nbt.appendTag(tag);
+ }
+ }
+ return nbt;
+ }
+
+ public void resetCurrency(UUID playerId, CurrencyItem.CurrencyType type) {
+ this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>());
+ if (type == null) {
+ this.playerCurrency.get(playerId)
+ .clear();
+ } else {
+ this.playerCurrency.get(playerId)
+ .put(type, 0);
+ }
+ this.hasCurrencyUpdate = true;
+ }
+
+ public void addCurrency(UUID playerId, CurrencyItem mapped) {
+ if (mapped != null) {
+ this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>());
+ this.playerCurrency.get(playerId)
+ .computeIfAbsent(mapped.type, k -> 0);
+ this.playerCurrency.get(playerId)
+ .put(
+ mapped.type,
+ this.playerCurrency.get(playerId)
+ .get(mapped.type) + mapped.value);
+ }
+ this.hasCurrencyUpdate = true;
+ }
}
diff --git a/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java b/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java
index adeef95..0dc391e 100644
--- a/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java
+++ b/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java
@@ -94,14 +94,14 @@ public BigItemStack setOreDict(@Nonnull String ore) {
/**
* Shortcut method to the NBTTagCompound in the base ItemStack
*/
- public NBTTagCompound GetTagCompound() {
+ public NBTTagCompound getTagCompound() {
return baseStack.getTagCompound();
}
/**
* Shortcut method to the NBTTagCompound in the base ItemStack
*/
- public void SetTagCompound(NBTTagCompound tags) {
+ public void setTagCompound(NBTTagCompound tags) {
baseStack.setTagCompound(tags);
}
@@ -109,7 +109,7 @@ public void SetTagCompound(NBTTagCompound tags) {
* Shortcut method to the NBTTagCompound in the base ItemStack
*/
@SuppressWarnings("WeakerAccess")
- public boolean HasTagCompound() {
+ public boolean hasTagCompound() {
return baseStack.hasTagCompound();
}
@@ -186,14 +186,24 @@ public static BigItemStack loadItemStackFromNBT(@Nonnull NBTTagCompound nbt) //
BigItemStack bigStack = new BigItemStack(miniStack);
bigStack.stackSize = nbt.getInteger("Count");
bigStack.setOreDict(nbt.getString("OreDict"));
- if (nbt.getShort("Damage") < 0) bigStack.baseStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
+ if (nbt.getInteger("Damage") < 0) bigStack.baseStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
return bigStack;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
- baseStack.writeToNBT(nbt);
- String iRes = Item.itemRegistry.getNameForObject(baseStack.getItem());
- nbt.setString("id", iRes == null ? "vendingmachine.placeholder" : iRes);
+ String itemName = Item.itemRegistry.getNameForObject(this.baseStack.getItem());
+ NBTTagCompound backupData = this.getTagCompound();
+ if (itemName.equals("vendingmachine:placeholder") && backupData != null) {
+ nbt.setString("id", backupData.getString("orig_id"));
+ nbt.setInteger("Damage", backupData.getInteger("orig_meta"));
+ if (backupData.hasKey("orig_tag")) {
+ nbt.setTag("tag", backupData.getCompoundTag("orig_tag"));
+ }
+ } else {
+ baseStack.writeToNBT(nbt);
+ String iRes = Item.itemRegistry.getNameForObject(baseStack.getItem());
+ nbt.setString("id", iRes == null ? "vendingmachine:placeholder" : iRes);
+ }
nbt.setInteger("Count", this.stackSize);
nbt.setString("OreDict", this.getOreDict());
return nbt;
diff --git a/src/main/java/com/cubefury/vendingmachine/util/FileIO.java b/src/main/java/com/cubefury/vendingmachine/util/FileIO.java
index 5185eea..54468bd 100644
--- a/src/main/java/com/cubefury/vendingmachine/util/FileIO.java
+++ b/src/main/java/com/cubefury/vendingmachine/util/FileIO.java
@@ -46,7 +46,7 @@ public static JsonObject ReadFromFile(File file) {
return GSON.fromJson(br, JsonObject.class);
} catch (Exception e) {
VendingMachine.LOG.error("Error reading JSON from file: ", e);
- File backup = new File(file.getParent(), "malformed_" + file.getName() + ".json");
+ File backup = new File(file.getParent(), "malformed_" + file.getName());
VendingMachine.LOG.error("Creating backup at: {}", backup.getAbsolutePath());
CopyPaste(file, backup);
diff --git a/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java b/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java
index 5f3a3cd..9caac56 100644
--- a/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java
+++ b/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java
@@ -26,13 +26,13 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count
NBTTagCompound nbt) {
if (item == null) {
BigItemStack stack = new BigItemStack(ItemPlaceholder.placeholder, count, damage);
- stack.SetTagCompound(new NBTTagCompound());
- stack.GetTagCompound()
+ stack.setTagCompound(new NBTTagCompound());
+ stack.getTagCompound()
.setString("orig_id", name);
- stack.GetTagCompound()
+ stack.getTagCompound()
.setInteger("orig_meta", damage);
if (nbt != null) {
- stack.GetTagCompound()
+ stack.getTagCompound()
.setTag("orig_tag", nbt);
}
return stack;
@@ -53,7 +53,7 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count
count,
nbt.hasKey("orig_meta") ? nbt.getInteger("orig_meta") : damage).setOreDict(oreDict);
if (nbt.hasKey("orig_tag")) {
- stack.SetTagCompound(nbt.getCompoundTag("orig_tag"));
+ stack.setTagCompound(nbt.getCompoundTag("orig_tag"));
}
return stack;
@@ -65,7 +65,7 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count
}
BigItemStack stack = new BigItemStack(item, count, damage).setOreDict(oreDict);
if (nbt != null) {
- stack.SetTagCompound(nbt);
+ stack.setTagCompound(nbt);
}
return stack;
diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang
index be90e15..47b908a 100644
--- a/src/main/resources/assets/vendingmachine/lang/en_US.lang
+++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang
@@ -10,6 +10,8 @@ vendingmachine.gui.neiColor.conditionDefault=000000
vendingmachine.gui.neiColor.conditionSatisfied=55D441
vendingmachine.gui.neiColor.conditionUnsatisfied=A87A5E
vendingmachine.gui.item_eject=Eject Items
+vendingmachine.gui.coin_eject=Eject All Coins
+vendingmachine.gui.single_coin_type_eject_hint=Shift-Click to Extract
vendingmachine.gui.search=Search
vendingmachine.gui.required_inputs=Requires:
@@ -18,6 +20,8 @@ vendingmachine.gui.cooldown_display.minute=m
vendingmachine.gui.cooldown_display.hour=h
vendingmachine.gui.cooldown_display.day=d
+vendingmachine.gui.error.player_using=Someone is using the vending machine at the moment.
+
gt.blockmachines.multimachine.vendingmachine.name=Vending Machine
vendingmachine.category.unknown=Unknown Category
@@ -29,3 +33,18 @@ vendingmachine.category.chemistry=Chemistry
vendingmachine.category.magic=Magic
vendingmachine.category.bees=Bees
vendingmachine.category.misc=Miscellaneous
+
+vendingmachine.coin.adventure=Adventure Coin
+vendingmachine.coin.bees=Bees Coin
+vendingmachine.coin.blood=Blood Magic Coin
+vendingmachine.coin.chemist=Chemistry Coin
+vendingmachine.coin.cook=Cook Coin
+vendingmachine.coin.darkWizard=Dark Wizard Coin
+vendingmachine.coin.farmer=Farming Coin
+vendingmachine.coin.flower=Flower Coin
+vendingmachine.coin.forestry=Forestry Coin
+vendingmachine.coin.smith=Smith Coin
+vendingmachine.coin.space=Space Coin
+vendingmachine.coin.survivor=Survivor Coin
+vendingmachine.coin.technician=Technician Coin
+vendingmachine.coin.witch=Witchery Coin
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png
new file mode 100644
index 0000000..ec3bc2c
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png
new file mode 100644
index 0000000..98e159d
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBlood.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBlood.png
new file mode 100644
index 0000000..1212f7d
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBlood.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png
new file mode 100644
index 0000000..c5f2ca3
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png
new file mode 100644
index 0000000..a39e441
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinDarkWizard.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinDarkWizard.png
new file mode 100644
index 0000000..1cd7b01
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinDarkWizard.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png
new file mode 100644
index 0000000..bd1661f
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png
new file mode 100644
index 0000000..ce3c23a
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinForestry.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinForestry.png
new file mode 100644
index 0000000..feb9468
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinForestry.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSmith.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSmith.png
new file mode 100644
index 0000000..98855aa
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSmith.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSpace.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSpace.png
new file mode 100644
index 0000000..17155bc
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSpace.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSurvivor.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSurvivor.png
new file mode 100644
index 0000000..1c3362a
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSurvivor.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinTechnician.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinTechnician.png
new file mode 100644
index 0000000..efcbd29
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinTechnician.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinWitch.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinWitch.png
new file mode 100644
index 0000000..890d83e
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinWitch.png differ
diff --git a/src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png b/src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png
new file mode 100644
index 0000000..ab26b18
Binary files /dev/null and b/src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png differ