Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef2fc209f1 | ||
|
|
26b88a5f27 | ||
|
|
87903fead7 | ||
|
|
1166c651d2 | ||
|
|
7f42cc1de8 | ||
|
|
ff3904ec1a | ||
|
|
c3671609d3 |
No files matched your search
@@ -1,17 +0,0 @@
|
|||||||
name: Optimize images
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [ master, main, release/** ]
|
|
||||||
paths:
|
|
||||||
- "**/*.png"
|
|
||||||
|
|
||||||
push:
|
|
||||||
branches: [ master, main, release/** ]
|
|
||||||
paths:
|
|
||||||
- "**/*.png"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
optimize-images:
|
|
||||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
|
||||||
secrets: inherit
|
|
||||||
@@ -5,7 +5,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- feature/doc
|
- feature/doc
|
||||||
- '**/*-javadoc'
|
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
delete:
|
delete:
|
||||||
|
|||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
javadoc {
|
javadoc {
|
||||||
javadocTool = javaToolchains.javadocToolFor {
|
javadocTool = javaToolchains.javadocToolFor {
|
||||||
// Last version with frames, but it also has search
|
// Last version with frames, but it also has search
|
||||||
languageVersion = JavaLanguageVersion.of(25)
|
languageVersion = JavaLanguageVersion.of(11)
|
||||||
vendor = JvmVendorSpec.ADOPTIUM
|
vendor = JvmVendorSpec.ADOPTIUM
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +18,9 @@ javadoc {
|
|||||||
|
|
||||||
options {
|
options {
|
||||||
overview "src/main/javadoc/overview.html"
|
overview "src/main/javadoc/overview.html"
|
||||||
links 'https://docs.oracle.com/en/java/javase/25/docs/api/'
|
links 'https://docs.oracle.com/javase/8/docs/api/'
|
||||||
links 'https://skmedix.github.io/ForgeJavaDocs/javadoc/forge/1.7.10-10.13.4.1614/'
|
links 'https://skmedix.github.io/ForgeJavaDocs/javadoc/forge/1.7.10-10.13.4.1614/'
|
||||||
|
addBooleanOption("-frames", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("com.github.GTNewHorizons:GTNHLib:0.11.18:dev")
|
api("com.github.GTNewHorizons:GTNHLib:0.7.1:dev")
|
||||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.104-GTNH:dev")
|
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.21-GTNH:dev")
|
||||||
|
|
||||||
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
||||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||||
testRuntimeOnly ('org.junit.platform:junit-platform-launcher')
|
|
||||||
}
|
}
|
||||||
@@ -39,33 +39,9 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
|||||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||||
developmentEnvironmentUserName = Developer
|
developmentEnvironmentUserName = Developer
|
||||||
|
|
||||||
# Enables modern Java syntax support. Valid values:
|
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||||
# - false: No modern syntax, Java 8 only
|
# See https://github.com/bsideup/jabel for details on how this works.
|
||||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
enableModernJavaSyntax = true
|
||||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
|
||||||
# - modern: Native modern Java bytecode, no downgrading
|
|
||||||
enableModernJavaSyntax = jabel
|
|
||||||
|
|
||||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
|
||||||
# and should *not* be used in most situations. -1 disables this.
|
|
||||||
# forceToolchainVersion = -1
|
|
||||||
|
|
||||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
|
||||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
|
||||||
# downgradeTargetVersion = 8
|
|
||||||
|
|
||||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
|
||||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
|
||||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
|
||||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
|
||||||
|
|
||||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
|
||||||
# - shade: Shade minimized stubs into the jar
|
|
||||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
|
||||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
|
||||||
# - (empty): Warning reminding you to configure stubs
|
|
||||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
|
||||||
# jvmDowngraderStubsProvider =
|
|
||||||
|
|
||||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||||
@@ -198,12 +174,6 @@ curseForgeRelations =
|
|||||||
# projects. New projects should not use this parameter.
|
# projects. New projects should not use this parameter.
|
||||||
# customArchiveBaseName =
|
# customArchiveBaseName =
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
|
||||||
# runClientWorkingDirectory = run/client
|
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
|
||||||
# runServerWorkingDirectory = run/server
|
|
||||||
|
|
||||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||||
# The check is ONLY performed if the version is a git tag.
|
# The check is ONLY performed if the version is a git tag.
|
||||||
@@ -233,6 +203,3 @@ curseForgeRelations =
|
|||||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||||
# ideaCheckSpotlessOnBuild = true
|
# ideaCheckSpotlessOnBuild = true
|
||||||
|
|
||||||
# Non-GTNH properties
|
|
||||||
org.gradle.configuration-cache = true
|
|
||||||
org.gradle.parallel = true
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#This file is generated by updateDaemonJvm
|
|
||||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
|
||||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
|
||||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
|
||||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
|
||||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
|
||||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
|
||||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
|
|
||||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
|
||||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
|
||||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d76df094a9cbbabd3b08251f9e61444a/redirect
|
|
||||||
toolchainVersion=25
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -114,6 +114,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -171,6 +172,7 @@ fi
|
|||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -210,7 +212,8 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
@@ -70,10 +70,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.26'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.47'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -346,7 +346,9 @@ public class ClientProxy extends CommonProxy {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof HintParticleInfo that)) return false;
|
if (!(o instanceof HintParticleInfo)) return false;
|
||||||
|
|
||||||
|
HintParticleInfo that = (HintParticleInfo) o;
|
||||||
|
|
||||||
return x == that.x && y == that.y && z == that.z;
|
return x == that.x && y == that.y && z == that.z;
|
||||||
}
|
}
|
||||||
@@ -395,6 +397,8 @@ public class ClientProxy extends CommonProxy {
|
|||||||
double worldY = y + 0.25;
|
double worldY = y + 0.25;
|
||||||
double worldZ = z + 0.25;
|
double worldZ = z + 0.25;
|
||||||
|
|
||||||
|
// this rendering code is independently written by glee8e on July 10th, 2023
|
||||||
|
// and is released as part of StructureLib under LGPL terms, just like everything else in this project
|
||||||
// cube is a very special model. its facings can be rendered correctly by viewer distance without using
|
// cube is a very special model. its facings can be rendered correctly by viewer distance without using
|
||||||
// surface normals and view vector
|
// surface normals and view vector
|
||||||
// here we do a 2 pass render.
|
// here we do a 2 pass render.
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class GuiEditRegistryConfig extends GuiScreen {
|
|||||||
/**
|
/**
|
||||||
* Adds the buttons (and other controls) to the screen in question.
|
* Adds the buttons (and other controls) to the screen in question.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
Keyboard.enableRepeatEvents(true);
|
Keyboard.enableRepeatEvents(true);
|
||||||
@@ -184,7 +185,8 @@ public class GuiEditRegistryConfig extends GuiScreen {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
if (this.configID != null && this.parentScreen instanceof GuiConfig parentGuiConfig) {
|
if (this.configID != null && this.parentScreen instanceof GuiConfig) {
|
||||||
|
GuiConfig parentGuiConfig = (GuiConfig) this.parentScreen;
|
||||||
parentGuiConfig.needsRefresh = true;
|
parentGuiConfig.needsRefresh = true;
|
||||||
parentGuiConfig.initGui();
|
parentGuiConfig.initGui();
|
||||||
}
|
}
|
||||||
@@ -317,16 +319,21 @@ public class GuiEditRegistryConfig extends GuiScreen {
|
|||||||
for (EntriesList list : lists) {
|
for (EntriesList list : lists) {
|
||||||
list.drawScreenPost(mouseX, mouseY, partialTicks);
|
list.drawScreenPost(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
if (this.undoHoverChecker.checkHover(mouseX, mouseY)) this.func_146283_a(
|
if (this.undoHoverChecker.checkHover(mouseX, mouseY)) this.drawToolTip(
|
||||||
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.undoAll"), 300),
|
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.undoAll"), 300),
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY);
|
mouseY);
|
||||||
if (this.resetHoverChecker.checkHover(mouseX, mouseY)) this.func_146283_a(
|
if (this.resetHoverChecker.checkHover(mouseX, mouseY)) this.drawToolTip(
|
||||||
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.resetAll"), 300),
|
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.resetAll"), 300),
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY);
|
mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void drawToolTip(List stringList, int x, int y) {
|
||||||
|
this.func_146283_a(stringList, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
private class EntriesList extends GuiListExtended {
|
private class EntriesList extends GuiListExtended {
|
||||||
|
|
||||||
final String heading;
|
final String heading;
|
||||||
@@ -564,13 +571,13 @@ public class GuiEditRegistryConfig extends GuiScreen {
|
|||||||
void drawToolTip(int mouseX, int mouseY) {
|
void drawToolTip(int mouseX, int mouseY) {
|
||||||
// ensure checkHover() is always called, or the hover threshold might fail under certain corner cases
|
// ensure checkHover() is always called, or the hover threshold might fail under certain corner cases
|
||||||
if (hoverCheckerText.checkHover(mouseX, mouseY)) {
|
if (hoverCheckerText.checkHover(mouseX, mouseY)) {
|
||||||
GuiEditRegistryConfig.this.func_146283_a(
|
GuiEditRegistryConfig.this.drawToolTip(
|
||||||
mc.fontRenderer.listFormattedStringToWidth(tooltip, entriesList.getListWidth()),
|
mc.fontRenderer.listFormattedStringToWidth(tooltip, entriesList.getListWidth()),
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY);
|
mouseY);
|
||||||
}
|
}
|
||||||
if (hoverCheckerBtnDrag.checkHover(mouseX, mouseY) && !isDragging) {
|
if (hoverCheckerBtnDrag.checkHover(mouseX, mouseY) && !isDragging) {
|
||||||
GuiEditRegistryConfig.this.func_146283_a(
|
GuiEditRegistryConfig.this.drawToolTip(
|
||||||
mc.fontRenderer.listFormattedStringToWidth(
|
mc.fontRenderer.listFormattedStringToWidth(
|
||||||
I18n.format("structurelib.configgui.drag.tooltip"),
|
I18n.format("structurelib.configgui.drag.tooltip"),
|
||||||
entriesList.getListWidth()),
|
entriesList.getListWidth()),
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class SortedRegistry<V> implements Iterable<V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup(MinecraftServer server) {
|
static void cleanup(MinecraftServer server) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<EntityPlayerMP> players = server.getConfigurationManager().playerEntityList;
|
List<EntityPlayerMP> players = server.getConfigurationManager().playerEntityList;
|
||||||
Set<UUID> onlinePlayerIDs = players.stream().map(EntityPlayerMP::getUniqueID).collect(Collectors.toSet());
|
Set<UUID> onlinePlayerIDs = players.stream().map(EntityPlayerMP::getUniqueID).collect(Collectors.toSet());
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ import static java.lang.Math.abs;
|
|||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Direction;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.Direction;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.CoordinateSystem;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.Position;
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
|
||||||
public class IntegerAxisSwap {
|
public class IntegerAxisSwap {
|
||||||
@@ -91,4 +95,32 @@ public class IntegerAxisSwap {
|
|||||||
out[1] = forFirstAxis.get1() * point[0] + forSecondAxis.get1() * point[1] + forThirdAxis.get1() * point[2];
|
out[1] = forFirstAxis.get1() * point[0] + forSecondAxis.get1() * point[1] + forThirdAxis.get1() * point[2];
|
||||||
out[2] = forFirstAxis.get2() * point[0] + forSecondAxis.get2() * point[1] + forThirdAxis.get2() * point[2];
|
out[2] = forFirstAxis.get2() * point[0] + forSecondAxis.get2() * point[1] + forThirdAxis.get2() * point[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3i translate(Vector3i point) {
|
||||||
|
return new Vector3i(
|
||||||
|
forFirstAxis.get0() * point.x() + forFirstAxis.get1() * point.y() + forFirstAxis.get2() * point.z(),
|
||||||
|
forSecondAxis.get0() * point.x() + forSecondAxis.get1() * point.y() + forSecondAxis.get2() * point.z(),
|
||||||
|
forThirdAxis.get0() * point.x() + forThirdAxis.get1() * point.y() + forThirdAxis.get2() * point.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i inverseTranslate(Vector3i point) {
|
||||||
|
return new Vector3i(
|
||||||
|
forFirstAxis.get0() * point.x() + forSecondAxis.get0() * point.y() + forThirdAxis.get0() * point.z(),
|
||||||
|
forFirstAxis.get1() * point.x() + forSecondAxis.get1() * point.y() + forThirdAxis.get1() * point.z(),
|
||||||
|
forFirstAxis.get2() * point.x() + forSecondAxis.get2() * point.y() + forThirdAxis.get2() * point.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <C extends CoordinateSystem<C, ?>> Position<C> translate(Position<?> point) {
|
||||||
|
return new Position<>(
|
||||||
|
forFirstAxis.get0() * point.x() + forFirstAxis.get1() * point.y() + forFirstAxis.get2() * point.z(),
|
||||||
|
forSecondAxis.get0() * point.x() + forSecondAxis.get1() * point.y() + forSecondAxis.get2() * point.z(),
|
||||||
|
forThirdAxis.get0() * point.x() + forThirdAxis.get1() * point.y() + forThirdAxis.get2() * point.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <C extends CoordinateSystem<C, ?>> Position<C> inverseTranslate(Position<?> point) {
|
||||||
|
return new Position<>(
|
||||||
|
forFirstAxis.get0() * point.x() + forSecondAxis.get0() * point.y() + forThirdAxis.get0() * point.z(),
|
||||||
|
forFirstAxis.get1() * point.x() + forSecondAxis.get1() * point.y() + forThirdAxis.get1() * point.z(),
|
||||||
|
forFirstAxis.get2() * point.x() + forSecondAxis.get2() * point.y() + forThirdAxis.get2() * point.z());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,8 @@ public class ConstructableUtility {
|
|||||||
|
|
||||||
if (constructable == null) return false;
|
if (constructable == null) return false;
|
||||||
|
|
||||||
if (aPlayer instanceof EntityPlayerMP playerMP) {
|
if (aPlayer instanceof EntityPlayerMP) {
|
||||||
|
EntityPlayerMP playerMP = (EntityPlayerMP) aPlayer;
|
||||||
// server side and sneaking (already checked above)
|
// server side and sneaking (already checked above)
|
||||||
// do construct
|
// do construct
|
||||||
if (aPlayer.capabilities.isCreativeMode) {
|
if (aPlayer.capabilities.isCreativeMode) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||||
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
|
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.StructureRelativeCoords;
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
|
||||||
public enum ExtendedFacing {
|
public enum ExtendedFacing {
|
||||||
@@ -166,6 +167,7 @@ public enum ExtendedFacing {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final IntegerAxisSwap integerAxisSwap;
|
private final IntegerAxisSwap integerAxisSwap;
|
||||||
|
private final StructureRelativeCoords coordinateSystem;
|
||||||
|
|
||||||
ExtendedFacing(String name) {
|
ExtendedFacing(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -247,6 +249,7 @@ public enum ExtendedFacing {
|
|||||||
this.b = b;
|
this.b = b;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
integerAxisSwap = new IntegerAxisSwap(a, b, c);
|
integerAxisSwap = new IntegerAxisSwap(a, b, c);
|
||||||
|
coordinateSystem = new StructureRelativeCoords(integerAxisSwap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExtendedFacing of(ForgeDirection direction, Rotation rotation, Flip flip) {
|
public static ExtendedFacing of(ForgeDirection direction, Rotation rotation, Flip flip) {
|
||||||
@@ -437,4 +440,8 @@ public enum ExtendedFacing {
|
|||||||
public ForgeDirection getRelativeForwardInWorld() {
|
public ForgeDirection getRelativeForwardInWorld() {
|
||||||
return c.getOpposite();
|
return c.getOpposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StructureRelativeCoords asCoordinateSystem() {
|
||||||
|
return coordinateSystem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -65,9 +65,10 @@ public class BlockHint extends Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
@SuppressWarnings("unchecked")
|
||||||
|
public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) {
|
||||||
for (int i = 0; i <= 15; i++) {
|
for (int i = 0; i <= 15; i++) {
|
||||||
list.add(new ItemStack(item, 1, i));
|
aList.add(new ItemStack(aItem, 1, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,9 @@ public class CommandConfigureChannels extends CommandBase {
|
|||||||
public void processCommand(ICommandSender sender, String[] args) {
|
public void processCommand(ICommandSender sender, String[] args) {
|
||||||
if (args.length == 0) throw new WrongUsageException(getCommandUsage(sender));
|
if (args.length == 0) throw new WrongUsageException(getCommandUsage(sender));
|
||||||
|
|
||||||
if (!(sender instanceof EntityPlayerMP player)) throw new WrongUsageException("must be a player");
|
if (!(sender instanceof EntityPlayerMP)) throw new WrongUsageException("must be a player");
|
||||||
|
|
||||||
|
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||||
|
|
||||||
ItemStack heldItem = player.getHeldItem();
|
ItemStack heldItem = player.getHeldItem();
|
||||||
if (heldItem == null || !(heldItem.getItem() instanceof ItemConstructableTrigger)) {
|
if (heldItem == null || !(heldItem.getItem() instanceof ItemConstructableTrigger)) {
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ public class CommandRegistryDebug extends CommandBase {
|
|||||||
public void processCommand(ICommandSender sender, String[] args) {
|
public void processCommand(ICommandSender sender, String[] args) {
|
||||||
if (args.length != 1) throw new WrongUsageException(getCommandUsage(sender));
|
if (args.length != 1) throw new WrongUsageException(getCommandUsage(sender));
|
||||||
|
|
||||||
if (!(sender instanceof EntityPlayerMP player)) throw new WrongUsageException("must be a player");
|
if (!(sender instanceof EntityPlayerMP)) throw new WrongUsageException("must be a player");
|
||||||
|
|
||||||
|
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||||
|
|
||||||
SortedRegistry<?> registry = SortedRegistry.getRegistry(args[0]);
|
SortedRegistry<?> registry = SortedRegistry.getRegistry(args[0]);
|
||||||
if (registry == null) throw new WrongUsageException("registry not found");
|
if (registry == null) throw new WrongUsageException("registry not found");
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller-relative coordinates. The controller is at 0,0,0. No axis swapping takes place, each axis points in the
|
||||||
|
* same directions as the matching world axis.
|
||||||
|
*/
|
||||||
|
public class ControllerRelativeCoords implements CoordinateSystem<ControllerRelativeCoords, WorldCoords> {
|
||||||
|
|
||||||
|
public final int controllerX, controllerY, controllerZ;
|
||||||
|
|
||||||
|
public ControllerRelativeCoords(int controllerX, int controllerY, int controllerZ) {
|
||||||
|
this.controllerX = controllerX;
|
||||||
|
this.controllerY = controllerY;
|
||||||
|
this.controllerZ = controllerZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<ControllerRelativeCoords> translate(Position<WorldCoords> position) {
|
||||||
|
return translate(position, controllerX, controllerY, controllerZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<WorldCoords> translateInverse(Position<ControllerRelativeCoords> position) {
|
||||||
|
return translateInverse(position, controllerX, controllerY, controllerZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Position<ControllerRelativeCoords> translate(Position<WorldCoords> position, int controllerX,
|
||||||
|
int controllerY, int controllerZ) {
|
||||||
|
position.sub(controllerX, controllerY, controllerZ);
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Position<WorldCoords> translateInverse(Position<ControllerRelativeCoords> position, int controllerX,
|
||||||
|
int controllerY, int controllerZ) {
|
||||||
|
position.add(controllerX, controllerY, controllerZ);
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A coordinate system is a statically-checked helper for determining which coordinates a {@link Position} has.
|
||||||
|
* Translation methods never copy a {@link Position} - if a position must remain unchanged, it must be copied
|
||||||
|
* separately. Most coordinate systems will have static methods that allow you to avoid allocations, though some (such
|
||||||
|
* as the ones provided by {@link ExtendedFacing#asCoordinateSystem()}) have no reason to be static.
|
||||||
|
*
|
||||||
|
* @param <Self>
|
||||||
|
* @param <Parent>
|
||||||
|
*/
|
||||||
|
public interface CoordinateSystem<Self extends CoordinateSystem<Self, Parent>, Parent extends CoordinateSystem<Parent, ?>> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates a position from the parent coordinate system into this one.
|
||||||
|
*/
|
||||||
|
Position<Self> translate(Position<Parent> position);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates a position from this coordinate system into the parent.
|
||||||
|
*/
|
||||||
|
Position<Parent> translateInverse(Position<Self> position);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method that converts a position's coordinate system. Should not be used unless you know it's correct.
|
||||||
|
*/
|
||||||
|
static <P1 extends CoordinateSystem<P1, ?>, P2 extends CoordinateSystem<P2, ?>> Position<P1> transmute(
|
||||||
|
Position<P2> pos) {
|
||||||
|
// noinspection unchecked
|
||||||
|
return (Position<P1>) pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||||
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link BlockPos} with a statically-checked coordinate system.
|
||||||
|
*/
|
||||||
|
public class Position<C extends CoordinateSystem<C, ?>> extends BlockPos {
|
||||||
|
|
||||||
|
public Position() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(int x, int y, int z) {
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(float x, float y, float z) {
|
||||||
|
super(MathHelper.floor_float(x), MathHelper.floor_float(y), MathHelper.floor_float(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(double x, double y, double z) {
|
||||||
|
super(MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(ChunkPosition chunkPosition) {
|
||||||
|
super(chunkPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(Vector3i v) {
|
||||||
|
super(v.x, v.y, v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(Vector3f v) {
|
||||||
|
this(v.x, v.y, v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(Vec3 v) {
|
||||||
|
this(v.xCoord, v.yCoord, v.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(Vec3Impl v) {
|
||||||
|
this(v.get0(), v.get1(), v.get2());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position<C> copy() {
|
||||||
|
return new Position<>(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i toVector3i() {
|
||||||
|
return new Vector3i(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f toVector3f() {
|
||||||
|
return new Vector3f(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3 toVec3() {
|
||||||
|
return Vec3.createVectorHelper(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3Impl toVec3Impl() {
|
||||||
|
return new Vec3Impl(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
/// The structure definition-local coords. 0,0,0 is the front-most left-most top-most element. Coordinates increase as
|
||||||
|
/// you go down, right, or back.
|
||||||
|
public class StructureDefinitionCoords implements CoordinateSystem<StructureDefinitionCoords, StructureRelativeCoords> {
|
||||||
|
|
||||||
|
public final int offsetX, offsetY, offsetZ;
|
||||||
|
|
||||||
|
public StructureDefinitionCoords(int offsetX, int offsetY, int offsetZ) {
|
||||||
|
this.offsetX = offsetX;
|
||||||
|
this.offsetY = offsetY;
|
||||||
|
this.offsetZ = offsetZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<StructureDefinitionCoords> translate(Position<StructureRelativeCoords> position) {
|
||||||
|
return translate(position, offsetX, offsetY, offsetZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<StructureRelativeCoords> translateInverse(Position<StructureDefinitionCoords> position) {
|
||||||
|
return translateInverse(position, offsetX, offsetY, offsetZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Position<StructureDefinitionCoords> translate(Position<StructureRelativeCoords> position, int offsetX,
|
||||||
|
int offsetY, int offsetZ) {
|
||||||
|
position.add(offsetX, offsetY, offsetZ);
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Position<StructureRelativeCoords> translateInverse(Position<StructureDefinitionCoords> position,
|
||||||
|
int offsetX, int offsetY, int offsetZ) {
|
||||||
|
position.sub(offsetX, offsetY, offsetZ);
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coordinates relative to the structure. 0,0,0 is the controller. 0,0,1 is the block immediately behind the controller
|
||||||
|
* (looking at it from its face). 1,0,0 is the block to the right of the controller. 0,1,0 is the block below the
|
||||||
|
* controller.
|
||||||
|
*/
|
||||||
|
public class StructureRelativeCoords implements CoordinateSystem<StructureRelativeCoords, ControllerRelativeCoords> {
|
||||||
|
|
||||||
|
public final IntegerAxisSwap axisSwap;
|
||||||
|
|
||||||
|
public StructureRelativeCoords(IntegerAxisSwap axisSwap) {
|
||||||
|
this.axisSwap = axisSwap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<StructureRelativeCoords> translate(Position<ControllerRelativeCoords> position) {
|
||||||
|
position.set(axisSwap.translate(position));
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<ControllerRelativeCoords> translateInverse(Position<StructureRelativeCoords> position) {
|
||||||
|
position.set(axisSwap.inverseTranslate(position));
|
||||||
|
|
||||||
|
return CoordinateSystem.transmute(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* World block coordinates
|
||||||
|
*/
|
||||||
|
public class WorldCoords implements CoordinateSystem<WorldCoords, WorldCoords> {
|
||||||
|
|
||||||
|
public static final WorldCoords INSTANCE = new WorldCoords();
|
||||||
|
|
||||||
|
private WorldCoords() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<WorldCoords> translate(Position<WorldCoords> position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<WorldCoords> translateInverse(Position<WorldCoords> position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -261,11 +261,6 @@ public class GuiScreenConfigureChannels extends GuiContainer implements IGuiScre
|
|||||||
switch (aKey) {
|
switch (aKey) {
|
||||||
case Keyboard.KEY_TAB:
|
case Keyboard.KEY_TAB:
|
||||||
if (key.isFocused()) {
|
if (key.isFocused()) {
|
||||||
if (autoCompleteList.getSelectedElement() != null) {
|
|
||||||
key.setText(autoCompleteList.getSelectedElement());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
key.setFocused(false);
|
key.setFocused(false);
|
||||||
value.setFocused(true);
|
value.setFocused(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ public class ItemBlockHint extends ItemBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
|
@SuppressWarnings("unchecked")
|
||||||
tooltip.add(translateToLocal("structurelib.blockhint.desc.0")); // Helps while building
|
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
|
||||||
switch (stack.getItemDamage()) {
|
aList.add(translateToLocal("structurelib.blockhint.desc.0")); // Helps while building
|
||||||
|
switch (aStack.getItemDamage()) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@@ -36,36 +37,35 @@ public class ItemBlockHint extends ItemBlock {
|
|||||||
case 9:
|
case 9:
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
// Placeholder for a certain group.
|
aList.add(
|
||||||
tooltip.add(
|
|
||||||
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
||||||
+ translateToLocal("structurelib.blockhint.desc.1"));
|
+ translateToLocal("structurelib.blockhint.desc.1")); // Placeholder for a certain
|
||||||
|
// group.
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
// General placeholder.
|
aList.add(
|
||||||
tooltip.add(
|
|
||||||
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
||||||
+ translateToLocal("structurelib.blockhint.desc.2"));
|
+ translateToLocal("structurelib.blockhint.desc.2")); // General placeholder.
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
// Make sure it contains Air material.
|
aList.add(
|
||||||
tooltip.add(
|
|
||||||
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
||||||
+ translateToLocal("structurelib.blockhint.desc.3"));
|
+ translateToLocal("structurelib.blockhint.desc.3")); // Make sure it contains Air
|
||||||
|
// material.
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
// Make sure it does not contain Air material.
|
aList.add(
|
||||||
tooltip.add(
|
|
||||||
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
|
||||||
+ translateToLocal("structurelib.blockhint.desc.4"));
|
+ translateToLocal("structurelib.blockhint.desc.4")); // Make sure it does not contain
|
||||||
|
// Air material.
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
// ERROR, what did u expect?
|
aList.add(EnumChatFormatting.BLUE + translateToLocal("structurelib.blockhint.desc.5")); // ERROR, what
|
||||||
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("structurelib.blockhint.desc.5"));
|
// did u expect?
|
||||||
break;
|
break;
|
||||||
default: // WTF?
|
default: // WTF?
|
||||||
tooltip.add("Damn son where did you get that!?");
|
aList.add("Damn son where did you get that!?");
|
||||||
tooltip.add(EnumChatFormatting.BLUE + "From outer space... I guess...");
|
aList.add(EnumChatFormatting.BLUE + "From outer space... I guess...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,30 +45,31 @@ public class ItemConstructableTrigger extends Item {
|
|||||||
return ConstructableUtility.handle(stack, player, world, x, y, z, side);
|
return ConstructableUtility.handle(stack, player, world, x, y, z, side);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
|
public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) {
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||||
tooltip.add(
|
aList.add(
|
||||||
translateToLocalFormatted(
|
translateToLocalFormatted(
|
||||||
"item.structurelib.constructableTrigger.desc.lshift.0",
|
"item.structurelib.constructableTrigger.desc.lshift.0",
|
||||||
ChannelDataAccessor.countChannelData(stack)));
|
ChannelDataAccessor.countChannelData(aStack)));
|
||||||
ChannelDataAccessor.iterateChannelData(stack).map(e -> e.getKey() + ": " + e.getValue())
|
ChannelDataAccessor.iterateChannelData(aStack).map(e -> e.getKey() + ": " + e.getValue())
|
||||||
.forEach(tooltip::add);
|
.forEach(aList::add);
|
||||||
} else {
|
} else {
|
||||||
// Tooltip text:
|
aList.add(translateToLocal("item.structurelib.constructableTrigger.desc.0")); // Triggers Constructable
|
||||||
// Triggers Constructable Interface
|
// Interface
|
||||||
// Shows multiblock construction details,
|
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.1")); // Shows multiblock
|
||||||
// just Use on a multiblock controller.
|
// construction
|
||||||
// (Sneak Use in creative to build)
|
// details,
|
||||||
// Quantity affects tier/mode/type
|
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.2")); // just Use on a
|
||||||
|
// multiblock
|
||||||
tooltip.add(translateToLocal("item.structurelib.constructableTrigger.desc.0"));
|
// controller.
|
||||||
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.1"));
|
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.3")); // (Sneak Use in
|
||||||
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.2"));
|
// creative to build)
|
||||||
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.3"));
|
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.4")); // Quantity affects
|
||||||
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.4"));
|
// tier/mode/type
|
||||||
if (ChannelDataAccessor.hasSubChannel(stack))
|
if (ChannelDataAccessor.hasSubChannel(aStack))
|
||||||
tooltip.add(translateToLocal("item.structurelib.constructableTrigger.desc.5"));
|
aList.add(translateToLocal("item.structurelib.constructableTrigger.desc.5"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,14 +34,15 @@ public class ItemFrontRotationTool extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
|
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List<String> aList, boolean p_77624_4_) {
|
||||||
// Tooltip Text:
|
aList.add(translateToLocal("item.structurelib.frontRotationTool.desc.0")); // Triggers Front Rotation Interface
|
||||||
// Triggers Front Rotation Interface
|
aList.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.1")); // Rotates
|
||||||
// Rotates only the front panel,
|
// only the
|
||||||
// which allows structure rotation.
|
// front
|
||||||
|
// panel,
|
||||||
tooltip.add(translateToLocal("item.structurelib.frontRotationTool.desc.0"));
|
aList.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.2")); // which
|
||||||
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.1"));
|
// allows
|
||||||
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.2"));
|
// structure
|
||||||
|
// rotation.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,9 @@ class ChatThrottleKey {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof NoExplicitChannel that)) return false;
|
if (!(o instanceof NoExplicitChannel)) return false;
|
||||||
|
|
||||||
|
NoExplicitChannel that = (NoExplicitChannel) o;
|
||||||
|
|
||||||
return subchannel.equals(that.subchannel);
|
return subchannel.equals(that.subchannel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package com.gtnewhorizon.structurelib.structure;
|
|||||||
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.ignoreBlockUnloaded;
|
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.ignoreBlockUnloaded;
|
||||||
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.skipBlockUnloaded;
|
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.skipBlockUnloaded;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -15,6 +18,8 @@ import com.gtnewhorizon.structurelib.StructureLibAPI;
|
|||||||
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
||||||
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
|
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.Position;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.StructureDefinitionCoords;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the structure definition of your multi. You will have one of these for each multi.
|
* This is the structure definition of your multi. You will have one of these for each multi.
|
||||||
@@ -335,6 +340,49 @@ public interface IStructureDefinition<T> {
|
|||||||
"customIterate");
|
"customIterate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the controller position for a piece. Controller positions are denoted by a tilde.
|
||||||
|
*
|
||||||
|
* @param piece The piece name
|
||||||
|
* @return The controller position, or null if it doesn't exist for the given piece
|
||||||
|
*/
|
||||||
|
Position<StructureDefinitionCoords> getControllerPosition(String piece);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the coordinate system for a piece. This is used to translate structure definition coordinates into structure
|
||||||
|
* relative coordinates.
|
||||||
|
*
|
||||||
|
* @param piece The piece
|
||||||
|
* @return The coordinate system
|
||||||
|
* @throws IllegalArgumentException When the piece does not exist
|
||||||
|
*/
|
||||||
|
StructureDefinitionCoords getCoordinateSystem(String piece);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a socket from a piece.
|
||||||
|
*
|
||||||
|
* @param piece The piece name
|
||||||
|
* @param socket The socket character
|
||||||
|
* @return The socket's position
|
||||||
|
* @throws IllegalArgumentException When the piece does not exist
|
||||||
|
* @throws IllegalArgumentException When the socket does not exist
|
||||||
|
* @throws IllegalStateException When more than one socket exists with this character
|
||||||
|
* @see StructureDefinition.Builder#addSocket(char, char)
|
||||||
|
*/
|
||||||
|
Position<StructureDefinitionCoords> getSocket(String piece, char socket);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all sockets with a given character for a piece.
|
||||||
|
*
|
||||||
|
* @param piece The piece name
|
||||||
|
* @param socket The socket character
|
||||||
|
* @return The list of socket positions, or an empty list if the socket is not present
|
||||||
|
* @throws IllegalArgumentException When the piece does not exist
|
||||||
|
* @see StructureDefinition.Builder#addSocket(char, char)
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
List<Position<StructureDefinitionCoords>> getAllSockets(String piece, char socket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level utility.
|
* Low level utility.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -43,30 +42,6 @@ public interface IStructureElement<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a human-readable description of what block(s) this element accepts. Used for diagnostic messages when
|
|
||||||
* structure checks fail (e.g. "expected Input Bus at (1, 2, 3)").
|
|
||||||
* <p>
|
|
||||||
* Unlike {@link #getBlocksToPlace}, which returns the full set of concrete block variants for autoplacing (e.g.
|
|
||||||
* every tier of Input Bus), this method returns <b>category-level</b> descriptions suitable for display to the
|
|
||||||
* player (e.g. just "Input Bus"). It also requires no parameters, no world, trigger item, or environment, making it
|
|
||||||
* usable in contexts where those are unavailable.
|
|
||||||
* <p>
|
|
||||||
* Implementations should return <b>lang keys</b> (e.g. {@code "tile.blockGlass.name"}) rather than pre-translated
|
|
||||||
* display names. The caller is responsible for translating these keys on the client side via
|
|
||||||
* {@code StatCollector.translateToLocal()}. If a key has no matching translation, {@code translateToLocal} returns
|
|
||||||
* the input string unchanged, so pre-translated fallback strings also work.
|
|
||||||
*
|
|
||||||
* @param context the context object (e.g. the multiblock controller), used to determine state-dependent
|
|
||||||
* descriptions
|
|
||||||
* @return a list of accepted block descriptions as lang keys (or display names as fallback), or null if no
|
|
||||||
* description is available
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
default List<String> getDescription(T context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger);
|
boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger);
|
||||||
|
|
||||||
boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger);
|
boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger);
|
||||||
@@ -96,7 +71,7 @@ public interface IStructureElement<T> {
|
|||||||
"Default implementation of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}",
|
"Default implementation of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}",
|
||||||
getClass().getName());
|
getClass().getName());
|
||||||
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
|
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
|
||||||
return PlaceResult.REJECT_CONTINUE;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +181,7 @@ public interface IStructureElement<T> {
|
|||||||
if (StructureLibAPI.isDebugEnabled()) LOGGER.info(
|
if (StructureLibAPI.isDebugEnabled()) LOGGER.info(
|
||||||
"Fallback shim code of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}",
|
"Fallback shim code of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}",
|
||||||
getClass().getName());
|
getClass().getName());
|
||||||
return PlaceResult.REJECT_CONTINUE;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,12 +204,6 @@ public interface IStructureElement<T> {
|
|||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return IStructureElement.this.spawnHint(t, world, x, y, z, trigger);
|
return IStructureElement.this.spawnHint(t, world, x, y, z, trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return IStructureElement.this.getDescription(context);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,21 +237,16 @@ public interface IStructureElement<T> {
|
|||||||
|
|
||||||
enum PlaceResult {
|
enum PlaceResult {
|
||||||
/**
|
/**
|
||||||
* The element's check passed, the position is already valid. No placement is needed. In the walker: continue
|
* This element either exists already, or does not yet have an implementation for survivalPlaceBlock, or some
|
||||||
* iteration (no error, not counted as placed). In ofChain: short-circuits, remaining alternatives are skipped.
|
* other unforeseen situations. TODO this definition doesn't seem right. Should we separate SKIP from EXISTS, or
|
||||||
|
* SKIP from ERROR?
|
||||||
*/
|
*/
|
||||||
SKIP,
|
SKIP,
|
||||||
/**
|
/**
|
||||||
* The element cannot handle this position (occupied, missing resources, etc.). In the walker: stop iteration
|
* This element's space is occupied by other stuff and require player attention, or player missing required
|
||||||
* with error particles. In ofChain: try next alternative.
|
* resource, or the block cannot be placed due to obscure mechanisms, or some other unforeseen situations.
|
||||||
*/
|
*/
|
||||||
REJECT,
|
REJECT,
|
||||||
/**
|
|
||||||
* This element has no survivalPlaceBlock implementation (default fallback), or otherwise cannot place but is
|
|
||||||
* not an error condition. In the walker: continue iteration silently (like SKIP). In ofChain: try next
|
|
||||||
* alternative (like REJECT), so a better-suited element can handle it.
|
|
||||||
*/
|
|
||||||
REJECT_CONTINUE,
|
|
||||||
/**
|
/**
|
||||||
* Autoplace cannot proceed within this tick. To proceed further would require stopping the placement and wait
|
* Autoplace cannot proceed within this tick. To proceed further would require stopping the placement and wait
|
||||||
* for next round.
|
* for next round.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -63,19 +61,6 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
default List<String> getDescription(T context) {
|
|
||||||
Set<String> descriptions = new LinkedHashSet<>();
|
|
||||||
for (IStructureElement<T> fallback : fallbacks()) {
|
|
||||||
List<String> desc = fallback.getDescription(context);
|
|
||||||
if (desc != null) {
|
|
||||||
descriptions.addAll(desc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return descriptions.isEmpty() ? null : new ArrayList<>(descriptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
default BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
|
default BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
|
||||||
@@ -97,51 +82,47 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
@Override
|
@Override
|
||||||
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s,
|
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s,
|
||||||
EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
|
EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
|
||||||
boolean allContinue = true;
|
boolean haveSkip = false;
|
||||||
List<IChatComponent> bufferedNoise = new ArrayList<>();
|
List<IChatComponent> bufferedNoise = new ArrayList<>();
|
||||||
for (IStructureElement<T> fallback : fallbacks()) {
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
PlaceResult result = fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, bufferedNoise::add);
|
PlaceResult result = fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, bufferedNoise::add);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case REJECT_CONTINUE:
|
|
||||||
break;
|
|
||||||
case REJECT:
|
case REJECT:
|
||||||
allContinue = false;
|
|
||||||
break;
|
break;
|
||||||
case SKIP:
|
case SKIP:
|
||||||
bufferedNoise.forEach(chatter);
|
haveSkip = true;
|
||||||
return PlaceResult.SKIP;
|
break;
|
||||||
default:
|
default:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// dump all that noise back into upstream
|
// dump all that noise back into upstream
|
||||||
bufferedNoise.forEach(chatter);
|
bufferedNoise.forEach(chatter);
|
||||||
return allContinue ? PlaceResult.REJECT_CONTINUE : PlaceResult.REJECT;
|
// TODO need reconsider to ensure this is the right course of action
|
||||||
|
return haveSkip ? PlaceResult.SKIP : PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
boolean allContinue = true;
|
boolean haveSkip = false;
|
||||||
List<IChatComponent> bufferedNoise = new ArrayList<>();
|
List<IChatComponent> bufferedNoise = new ArrayList<>();
|
||||||
for (IStructureElement<T> fallback : fallbacks()) {
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
PlaceResult result = fallback
|
PlaceResult result = fallback
|
||||||
.survivalPlaceBlock(t, world, x, y, z, trigger, env.withChatter(bufferedNoise::add));
|
.survivalPlaceBlock(t, world, x, y, z, trigger, env.withChatter(bufferedNoise::add));
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case REJECT_CONTINUE:
|
|
||||||
break;
|
|
||||||
case REJECT:
|
case REJECT:
|
||||||
allContinue = false;
|
|
||||||
break;
|
break;
|
||||||
case SKIP:
|
case SKIP:
|
||||||
bufferedNoise.forEach(env.getChatter());
|
haveSkip = true;
|
||||||
return PlaceResult.SKIP;
|
break;
|
||||||
default:
|
default:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// dump all that noise back into upstream
|
// dump all that noise back into upstream
|
||||||
bufferedNoise.forEach(env.getChatter());
|
bufferedNoise.forEach(env.getChatter());
|
||||||
return allContinue ? PlaceResult.REJECT_CONTINUE : PlaceResult.REJECT;
|
// TODO need reconsider to ensure this is the right course of action
|
||||||
|
return haveSkip ? PlaceResult.SKIP : PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,12 +27,12 @@ public interface IStructureElementCheckOnly<T> extends IStructureElement<T> {
|
|||||||
@Override
|
@Override
|
||||||
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s,
|
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s,
|
||||||
EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
|
EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
|
||||||
return PlaceResult.REJECT_CONTINUE;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return PlaceResult.REJECT_CONTINUE;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@@ -66,10 +65,4 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return elem != null ? elem.getDescription(context) : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,33 +4,49 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir;
|
|||||||
import static com.gtnewhorizon.structurelib.structure.StructureUtility.notAir;
|
import static com.gtnewhorizon.structurelib.structure.StructureUtility.notAir;
|
||||||
import static com.gtnewhorizon.structurelib.structure.StructureUtility.step;
|
import static com.gtnewhorizon.structurelib.structure.StructureUtility.step;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import com.google.common.collect.ListMultimap;
|
||||||
|
import com.google.common.collect.MultimapBuilder;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.Position;
|
||||||
|
import com.gtnewhorizon.structurelib.coords.StructureDefinitionCoords;
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.chars.Char2CharOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.chars.CharOpenHashSet;
|
||||||
|
|
||||||
public class StructureDefinition<T> implements IStructureDefinition<T> {
|
public class StructureDefinition<T> implements IStructureDefinition<T> {
|
||||||
|
|
||||||
private final Map<Character, IStructureElement<T>> elements;
|
private final Map<Character, IStructureElement<T>> elements;
|
||||||
private final Map<String, String> shapes;
|
private final Map<String, String> shapes;
|
||||||
private final Map<String, IStructureElement<T>[]> structures;
|
private final Map<String, IStructureElement<T>[]> structures;
|
||||||
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
||||||
|
private final Map<String, Position<StructureDefinitionCoords>> controllers;
|
||||||
|
private final Map<String, ListMultimap<Character, Position<StructureDefinitionCoords>>> socketLocations;
|
||||||
|
|
||||||
public static <B> Builder<B> builder() {
|
public static <B> Builder<B> builder() {
|
||||||
return new Builder<>();
|
return new Builder<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private StructureDefinition(Map<Character, IStructureElement<T>> elements, Map<String, String> shapes,
|
private StructureDefinition(Map<Character, IStructureElement<T>> elements, Map<String, String> shapes,
|
||||||
Map<String, IStructureElement<T>[]> structures, Map<String, Set<Vec3Impl>> occupiedSpaces) {
|
Map<String, IStructureElement<T>[]> structures, Map<String, Set<Vec3Impl>> occupiedSpaces,
|
||||||
|
Map<String, Position<StructureDefinitionCoords>> controllers,
|
||||||
|
Map<String, ListMultimap<Character, Position<StructureDefinitionCoords>>> socketLocations) {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.shapes = shapes;
|
this.shapes = shapes;
|
||||||
this.structures = structures;
|
this.structures = structures;
|
||||||
this.occupiedSpaces = occupiedSpaces;
|
this.occupiedSpaces = occupiedSpaces;
|
||||||
|
this.controllers = controllers;
|
||||||
|
this.socketLocations = socketLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T> {
|
public static class Builder<T> {
|
||||||
@@ -41,12 +57,18 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
private char d = '\uD000';
|
private char d = '\uD000';
|
||||||
private final Map<Vec3Impl, Character> navigates;
|
private final Map<Vec3Impl, Character> navigates;
|
||||||
private final Map<Character, IStructureElement<T>> elements;
|
private final Map<Character, IStructureElement<T>> elements;
|
||||||
|
private final Map<String, String[][]> uncompiledShapes;
|
||||||
private final Map<String, String> shapes;
|
private final Map<String, String> shapes;
|
||||||
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
||||||
|
|
||||||
|
private final Map<String, Position<StructureDefinitionCoords>> controllers = new HashMap<>();
|
||||||
|
private final Char2CharOpenHashMap socketTranslations = new Char2CharOpenHashMap();
|
||||||
|
private final Map<String, ListMultimap<Character, Position<StructureDefinitionCoords>>> socketLocations = new HashMap<>();
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
navigates = new HashMap<>();
|
navigates = new HashMap<>();
|
||||||
elements = new HashMap<>();
|
elements = new HashMap<>();
|
||||||
|
uncompiledShapes = new HashMap<>();
|
||||||
shapes = new HashMap<>();
|
shapes = new HashMap<>();
|
||||||
occupiedSpaces = new HashMap<>();
|
occupiedSpaces = new HashMap<>();
|
||||||
}
|
}
|
||||||
@@ -82,7 +104,69 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public Builder<T> addShape(String name, String[][] structurePiece) {
|
public Builder<T> addShape(String name, String[][] structurePiece) {
|
||||||
|
uncompiledShapes.put(name, structurePiece);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use the unboxed version
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Builder<T> addElement(Character name, IStructureElement<T> structurePiece) {
|
||||||
|
elements.putIfAbsent(name, structurePiece);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> addElement(char name, IStructureElement<T> structurePiece) {
|
||||||
|
elements.putIfAbsent(name, structurePiece);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes {@code name} as a socket. Sockets are virtual structure elements that record their position in the
|
||||||
|
* structure for future retrieval. They are transformed into real structure elements and do not need their own
|
||||||
|
* element (see {@code replacement}).
|
||||||
|
*
|
||||||
|
* @param name The socket name character
|
||||||
|
* @param replacement The replacement character
|
||||||
|
* @see IStructureDefinition#getSocket(String, char)
|
||||||
|
* @see IStructureDefinition#getAllSockets(String, char)
|
||||||
|
*/
|
||||||
|
public Builder<T> addSocket(char name, char replacement) {
|
||||||
|
socketTranslations.put(name, replacement);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link #addSocket(char, char)} but without the replacement. The structure must have a structure element
|
||||||
|
* with the given character.
|
||||||
|
*
|
||||||
|
* @param name The socket name character
|
||||||
|
*/
|
||||||
|
public Builder<T> addSocket(char name) {
|
||||||
|
// Adding a name -> name entry like this isn't ideal but this is the cleanest solution
|
||||||
|
socketTranslations.put(name, name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IStructureDefinition<T> build() {
|
||||||
|
uncompiledShapes.forEach(this::compileShape);
|
||||||
|
|
||||||
|
Map<String, IStructureElement<T>[]> structures = compileStructureMap();
|
||||||
|
|
||||||
|
return new StructureDefinition<>(
|
||||||
|
new HashMap<>(elements),
|
||||||
|
new HashMap<>(shapes),
|
||||||
|
structures,
|
||||||
|
occupiedSpaces,
|
||||||
|
controllers,
|
||||||
|
socketLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void compileShape(String name, String[][] structurePiece) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
if (structurePiece.length > 0) {
|
if (structurePiece.length > 0) {
|
||||||
for (String[] strings : structurePiece) {
|
for (String[] strings : structurePiece) {
|
||||||
if (strings.length > 0) {
|
if (strings.length > 0) {
|
||||||
@@ -95,6 +179,11 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
}
|
}
|
||||||
builder.setLength(builder.length() - 1);
|
builder.setLength(builder.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always create a map for this piece, even if it doesn't have any sockets
|
||||||
|
// noinspection UnstableApiUsage
|
||||||
|
socketLocations.put(name, MultimapBuilder.hashKeys().arrayListValues().build());
|
||||||
|
|
||||||
Set<Vec3Impl> occupiedSpace = new HashSet<>();
|
Set<Vec3Impl> occupiedSpace = new HashSet<>();
|
||||||
// these track the global current location
|
// these track the global current location
|
||||||
int aa = 0, bb = 0, cc = 0;
|
int aa = 0, bb = 0, cc = 0;
|
||||||
@@ -103,6 +192,15 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
// I do know these are pretty bad variable naming, but I have no better idea
|
// I do know these are pretty bad variable naming, but I have no better idea
|
||||||
for (int i = 0; i < builder.length(); i++) {
|
for (int i = 0; i < builder.length(); i++) {
|
||||||
char ch = builder.charAt(i);
|
char ch = builder.charAt(i);
|
||||||
|
|
||||||
|
// Translate the element char if it's a socket, and record the socket position
|
||||||
|
if (socketTranslations.containsKey(ch)) {
|
||||||
|
socketLocations.get(name).put(ch, new Position<>(aa, bb, cc));
|
||||||
|
|
||||||
|
ch = socketTranslations.get(ch);
|
||||||
|
builder.setCharAt(i, ch);
|
||||||
|
}
|
||||||
|
|
||||||
if (ch == ' ') {
|
if (ch == ' ') {
|
||||||
builder.setCharAt(i, A);
|
builder.setCharAt(i, A);
|
||||||
ch = A;
|
ch = A;
|
||||||
@@ -110,6 +208,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
builder.setCharAt(i, A);
|
builder.setCharAt(i, A);
|
||||||
ch = A;
|
ch = A;
|
||||||
occupiedSpace.add(Vec3Impl.getFromPool(aa, bb, cc));
|
occupiedSpace.add(Vec3Impl.getFromPool(aa, bb, cc));
|
||||||
|
controllers.put(name, new Position<>(aa, bb, cc));
|
||||||
}
|
}
|
||||||
if (ch == A) {
|
if (ch == A) {
|
||||||
aa++;
|
aa++;
|
||||||
@@ -148,93 +247,70 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
|
|
||||||
occupiedSpaces.put(name, occupiedSpace);
|
occupiedSpaces.put(name, occupiedSpace);
|
||||||
|
|
||||||
boolean hasPlus = false;
|
String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]", "");
|
||||||
boolean hasMinus = false;
|
|
||||||
|
|
||||||
int write = 0;
|
if (built.contains("+")) {
|
||||||
for (int read = 0; read < builder.length(); read++) {
|
|
||||||
char ch = builder.charAt(read);
|
|
||||||
if (ch == A || ch == B || ch == C) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ch == '+') {
|
|
||||||
hasPlus = true;
|
|
||||||
} else if (ch == '-') {
|
|
||||||
hasMinus = true;
|
|
||||||
}
|
|
||||||
if (read != write) builder.setCharAt(write, ch);
|
|
||||||
write++;
|
|
||||||
}
|
|
||||||
builder.setLength(write);
|
|
||||||
|
|
||||||
if (hasPlus) {
|
|
||||||
addElement('+', notAir());
|
addElement('+', notAir());
|
||||||
}
|
}
|
||||||
if (hasMinus) {
|
if (built.contains("-")) {
|
||||||
addElement('-', isAir());
|
addElement('-', isAir());
|
||||||
}
|
}
|
||||||
shapes.put(name, builder.toString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
shapes.put(name, built);
|
||||||
* @deprecated use the unboxed version
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Builder<T> addElement(Character name, IStructureElement<T> structurePiece) {
|
|
||||||
elements.putIfAbsent(name, structurePiece);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder<T> addElement(char name, IStructureElement<T> structurePiece) {
|
|
||||||
elements.putIfAbsent(name, structurePiece);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IStructureDefinition<T> build() {
|
|
||||||
Map<String, IStructureElement<T>[]> structures = compileStructureMap();
|
|
||||||
return new StructureDefinition<>(
|
|
||||||
new HashMap<>(elements),
|
|
||||||
new HashMap<>(shapes),
|
|
||||||
structures,
|
|
||||||
occupiedSpaces);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private Map<String, IStructureElement<T>[]> compileElementSetMap() {
|
|
||||||
Set<Integer> missing = findMissing();
|
|
||||||
if (missing.isEmpty()) {
|
|
||||||
return shapes.entrySet().stream().collect(
|
|
||||||
Collectors.toMap(
|
|
||||||
Map.Entry::getKey,
|
|
||||||
e -> e.getValue().chars().mapToObj(c -> (char) c).distinct().map(elements::get)
|
|
||||||
.toArray(IStructureElement[]::new)));
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Missing Structure Element bindings for (chars as integers): "
|
|
||||||
+ Arrays.toString(missing.toArray()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, IStructureElement<T>[]> compileStructureMap() {
|
private Map<String, IStructureElement<T>[]> compileStructureMap() {
|
||||||
Set<Integer> missing = findMissing();
|
CharOpenHashSet missing = findMissing();
|
||||||
if (missing.isEmpty()) {
|
|
||||||
return shapes.entrySet().stream().collect(
|
if (!missing.isEmpty()) {
|
||||||
Collectors.toMap(
|
throw new RuntimeException("Missing Structure Element bindings for: " + missing);
|
||||||
Map.Entry::getKey,
|
|
||||||
e -> e.getValue().chars().mapToObj(c -> elements.get((char) c))
|
|
||||||
.toArray(IStructureElement[]::new)));
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Missing Structure Element bindings for (chars as integers): "
|
|
||||||
+ Arrays.toString(missing.toArray()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, IStructureElement<T>[]> map = new HashMap<>();
|
||||||
|
|
||||||
|
for (Entry<String, String> e : shapes.entrySet()) {
|
||||||
|
char[] chars = e.getValue().toCharArray();
|
||||||
|
IStructureElement<T>[] compiled = new IStructureElement[chars.length];
|
||||||
|
|
||||||
|
int a = 0, b = 0, c = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < chars.length; i++) {
|
||||||
|
char ch = chars[i];
|
||||||
|
|
||||||
|
IStructureElement<T> element = this.elements.get(ch);
|
||||||
|
|
||||||
|
compiled[i] = element;
|
||||||
|
|
||||||
|
if (element.isNavigating()) {
|
||||||
|
a = (element.resetA() ? 0 : a) + element.getStepA();
|
||||||
|
b = (element.resetB() ? 0 : b) + element.getStepB();
|
||||||
|
c = (element.resetC() ? 0 : c) + element.getStepC();
|
||||||
|
} else {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map.put(e.getKey(), compiled) != null) {
|
||||||
|
throw new IllegalStateException("Duplicate shape: " + e.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Integer> findMissing() {
|
private CharOpenHashSet findMissing() {
|
||||||
return shapes.values().stream().flatMapToInt(CharSequence::chars)
|
CharOpenHashSet missing = new CharOpenHashSet();
|
||||||
.filter(i -> !elements.containsKey((char) i)).boxed().collect(Collectors.toSet());
|
|
||||||
|
for (String shape : shapes.values()) {
|
||||||
|
for (char c : shape.toCharArray()) {
|
||||||
|
if (!elements.containsKey(c)) {
|
||||||
|
missing.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return missing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,4 +339,61 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
if (occupiedSpace == null) throw new NoSuchElementException(name);
|
if (occupiedSpace == null) throw new NoSuchElementException(name);
|
||||||
return occupiedSpace.contains(new Vec3Impl(offsetA, offsetB, offsetC));
|
return occupiedSpace.contains(new Vec3Impl(offsetA, offsetB, offsetC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<StructureDefinitionCoords> getControllerPosition(String piece) {
|
||||||
|
return controllers.get(piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructureDefinitionCoords getCoordinateSystem(String piece) {
|
||||||
|
var controller = controllers.get(piece);
|
||||||
|
|
||||||
|
if (controller == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid piece: " + piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StructureDefinitionCoords(controller.x, controller.y, controller.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position<StructureDefinitionCoords> getSocket(String piece, char socket) {
|
||||||
|
var piecePositions = socketLocations.get(piece);
|
||||||
|
|
||||||
|
if (piecePositions == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid piece: " + piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
var positions = piecePositions.get(socket);
|
||||||
|
|
||||||
|
if (positions.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Socket " + socket + " for piece " + piece + " does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positions.size() > 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Socket " + socket
|
||||||
|
+ " for piece "
|
||||||
|
+ piece
|
||||||
|
+ " has several positions, but expected one and only one");
|
||||||
|
}
|
||||||
|
|
||||||
|
return positions.get(0).copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public List<Position<StructureDefinitionCoords>> getAllSockets(String piece, char socket) {
|
||||||
|
var piecePositions = socketLocations.get(piece);
|
||||||
|
|
||||||
|
if (piecePositions == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid piece: " + piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = new ArrayList<>(piecePositions.get(socket));
|
||||||
|
|
||||||
|
list.replaceAll(Position::copy);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -36,10 +36,7 @@ import net.minecraft.item.ItemBlock;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
import net.minecraft.util.ChatStyle;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -341,10 +338,13 @@ public class StructureUtility {
|
|||||||
ItemStack stack = new ItemStack(itemBlock, 1, itemMeta);
|
ItemStack stack = new ItemStack(itemBlock, 1, itemMeta);
|
||||||
if (!s.takeOne(stack, true)) {
|
if (!s.takeOne(stack, true)) {
|
||||||
if (chatter != null) chatter.accept(
|
if (chatter != null) chatter.accept(
|
||||||
new ChatComponentTranslation("structurelib.autoplace.missing_block", stack.func_151000_E()));
|
new ChatComponentTranslation(
|
||||||
|
"structurelib.autoplace.error.no_simple_block",
|
||||||
|
stack.func_151000_E()));
|
||||||
return PlaceResult.REJECT;
|
return PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
if (block instanceof ICustomBlockSetting blockCustom) {
|
if (block instanceof ICustomBlockSetting) {
|
||||||
|
ICustomBlockSetting blockCustom = (ICustomBlockSetting) block;
|
||||||
blockCustom.setBlock(world, x, y, z, meta);
|
blockCustom.setBlock(world, x, y, z, meta);
|
||||||
} else if (!stack.copy()
|
} else if (!stack.copy()
|
||||||
.tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f)) {
|
.tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f)) {
|
||||||
@@ -447,7 +447,7 @@ public class StructureUtility {
|
|||||||
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
|
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
|
||||||
if (!assumeStackPresent && !s.takeOne(stack, true)) {
|
if (!assumeStackPresent && !s.takeOne(stack, true)) {
|
||||||
if (chatter != null) chatter.accept(
|
if (chatter != null) chatter.accept(
|
||||||
new ChatComponentTranslation("structurelib.autoplace.missing_block", stack.func_151000_E()));
|
new ChatComponentTranslation("structurelib.autoplace.error.no_item_stack", stack.func_151000_E()));
|
||||||
return PlaceResult.REJECT;
|
return PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
if (!stack.copy().tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f))
|
if (!stack.copy().tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f))
|
||||||
@@ -637,7 +637,7 @@ public class StructureUtility {
|
|||||||
* given tier, then player will be allowed to use multiple kinds of blocks, but their tier is guaranteed to be the
|
* given tier, then player will be allowed to use multiple kinds of blocks, but their tier is guaranteed to be the
|
||||||
* same.
|
* same.
|
||||||
* <p>
|
* <p>
|
||||||
* <h4>WARNING</h4> <b>You SHOULD NOT return notSet from your tierExtractor.</b> If you do so, we will have this
|
* <h3>WARNING</h3> <b>You SHOULD NOT return notSet from your tierExtractor.</b> If you do so, we will have this
|
||||||
* chain of events:
|
* chain of events:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>at check start, tier is reset to notSet
|
* <li>at check start, tier is reset to notSet
|
||||||
@@ -650,7 +650,7 @@ public class StructureUtility {
|
|||||||
* doing its business
|
* doing its business
|
||||||
* <li>Player enjoy a (probably) hilariously shaped multi and (probably) reduced build cost.
|
* <li>Player enjoy a (probably) hilariously shaped multi and (probably) reduced build cost.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <h4>Example Implementation</h4>
|
* <h3>Example Implementation</h3>
|
||||||
* <p>
|
* <p>
|
||||||
* Assume you have 16 tier, each map to one particular block's 16 different meta. You will usually want something
|
* Assume you have 16 tier, each map to one particular block's 16 different meta. You will usually want something
|
||||||
* like this
|
* like this
|
||||||
@@ -706,29 +706,6 @@ public class StructureUtility {
|
|||||||
public static <T, TIER> IStructureElement<T> ofBlocksTiered(ITierConverter<TIER> tierExtractor,
|
public static <T, TIER> IStructureElement<T> ofBlocksTiered(ITierConverter<TIER> tierExtractor,
|
||||||
@Nullable List<Pair<Block, Integer>> allKnownTiers, @Nullable TIER notSet, BiConsumer<T, TIER> setter,
|
@Nullable List<Pair<Block, Integer>> allKnownTiers, @Nullable TIER notSet, BiConsumer<T, TIER> setter,
|
||||||
Function<T, TIER> getter) {
|
Function<T, TIER> getter) {
|
||||||
List<String> descriptions = null;
|
|
||||||
if (allKnownTiers != null) {
|
|
||||||
descriptions = new java.util.ArrayList<>();
|
|
||||||
for (Pair<Block, Integer> tier : allKnownTiers) {
|
|
||||||
Item item = Item.getItemFromBlock(tier.getLeft());
|
|
||||||
if (item != null) {
|
|
||||||
descriptions.add(new ItemStack(item, 1, tier.getRight()).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ofBlocksTiered(tierExtractor, allKnownTiers, notSet, setter, getter, descriptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Like {@link #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)}, but with an explicit
|
|
||||||
* description that will be returned by {@link IStructureElement#getDescription(Object)}.
|
|
||||||
*
|
|
||||||
* @param description the description lang keys to attach to this element, or null for no description
|
|
||||||
* @see #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)
|
|
||||||
*/
|
|
||||||
public static <T, TIER> IStructureElement<T> ofBlocksTiered(ITierConverter<TIER> tierExtractor,
|
|
||||||
@Nullable List<Pair<Block, Integer>> allKnownTiers, @Nullable TIER notSet, BiConsumer<T, TIER> setter,
|
|
||||||
Function<T, TIER> getter, @Nullable List<String> description) {
|
|
||||||
List<Pair<Block, Integer>> hints = allKnownTiers == null ? Collections.emptyList() : allKnownTiers;
|
List<Pair<Block, Integer>> hints = allKnownTiers == null ? Collections.emptyList() : allKnownTiers;
|
||||||
if (hints.stream().anyMatch(Objects::isNull)) throw new IllegalArgumentException();
|
if (hints.stream().anyMatch(Objects::isNull)) throw new IllegalArgumentException();
|
||||||
IStructureElementCheckOnly<T> check = ofBlocksTiered(tierExtractor, notSet, setter, getter);
|
IStructureElementCheckOnly<T> check = ofBlocksTiered(tierExtractor, notSet, setter, getter);
|
||||||
@@ -769,7 +746,8 @@ public class StructureUtility {
|
|||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
Pair<Block, Integer> hint = getHint(trigger);
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
if (hint == null) return false;
|
if (hint == null) return false;
|
||||||
if (hint.getKey() instanceof ICustomBlockSetting block) {
|
if (hint.getKey() instanceof ICustomBlockSetting) {
|
||||||
|
ICustomBlockSetting block = (ICustomBlockSetting) hint.getKey();
|
||||||
block.setBlock(world, x, y, z, hint.getValue());
|
block.setBlock(world, x, y, z, hint.getValue());
|
||||||
} else {
|
} else {
|
||||||
world.setBlock(x, y, z, hint.getKey(), hint.getValue(), 2);
|
world.setBlock(x, y, z, hint.getKey(), hint.getValue(), 2);
|
||||||
@@ -789,7 +767,7 @@ public class StructureUtility {
|
|||||||
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
Pair<Block, Integer> hint = getHint(trigger);
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
if (hint == null) return PlaceResult.REJECT;
|
if (hint == null) return PlaceResult.REJECT; // TODO or SKIP?
|
||||||
Block block = world.getBlock(x, y, z);
|
Block block = world.getBlock(x, y, z);
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
TIER tier = tierExtractor.convert(block, meta);
|
TIER tier = tierExtractor.convert(block, meta);
|
||||||
@@ -806,24 +784,6 @@ public class StructureUtility {
|
|||||||
env.getActor(),
|
env.getActor(),
|
||||||
env.getChatter());
|
env.getChatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
TIER currentTier = getter.apply(context);
|
|
||||||
if (Objects.equals(currentTier, notSet)) return description;
|
|
||||||
|
|
||||||
for (Pair<Block, Integer> pair : hints) {
|
|
||||||
TIER pairTier = tierExtractor.convert(pair.getKey(), pair.getValue());
|
|
||||||
if (!Objects.equals(pairTier, currentTier)) continue;
|
|
||||||
Item item = Item.getItemFromBlock(pair.getKey());
|
|
||||||
if (item == null) continue;
|
|
||||||
return Collections
|
|
||||||
.singletonList(new ItemStack(item, 1, pair.getValue()).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1447,65 +1407,10 @@ public class StructureUtility {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return BlocksToPlace.create(block, meta);
|
return BlocksToPlace.create(block, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if (item == null) return null;
|
|
||||||
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return new IStructureElement<T>() {
|
return new IStructureElement<T>() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
|
||||||
AutoPlaceEnvironment env) {
|
|
||||||
BlocksToPlace e = getBlocksToPlace(t, world, x, y, z, trigger, env);
|
|
||||||
IItemSource source = env.getSource();
|
|
||||||
EntityPlayer actor = env.getActor();
|
|
||||||
Consumer<IChatComponent> chatter = env.getChatter();
|
|
||||||
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
|
|
||||||
if (e.getStacks() == null) {
|
|
||||||
ItemStack taken = source.takeOne(e.getPredicate(), true);
|
|
||||||
return StructureUtility.survivalPlaceBlock(
|
|
||||||
taken,
|
|
||||||
NBTMode.EXACT,
|
|
||||||
taken.stackTagCompound,
|
|
||||||
false,
|
|
||||||
world,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
source,
|
|
||||||
actor,
|
|
||||||
chatter);
|
|
||||||
}
|
|
||||||
for (ItemStack stack : e.getStacks()) {
|
|
||||||
if (!source.takeOne(stack, true)) {
|
|
||||||
IChatComponent name = new ChatComponentText(stack.getDisplayName());
|
|
||||||
name.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW));
|
|
||||||
env.getChatter()
|
|
||||||
.accept(new ChatComponentTranslation("structurelib.autoplace.missing_block", name));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return StructureUtility.survivalPlaceBlock(
|
|
||||||
stack,
|
|
||||||
NBTMode.EXACT,
|
|
||||||
stack.stackTagCompound,
|
|
||||||
false,
|
|
||||||
world,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
source,
|
|
||||||
actor,
|
|
||||||
chatter);
|
|
||||||
}
|
|
||||||
return PlaceResult.REJECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(T t, World world, int x, int y, int z) {
|
public boolean check(T t, World world, int x, int y, int z) {
|
||||||
Block worldBlock = world.getBlock(x, y, z);
|
Block worldBlock = world.getBlock(x, y, z);
|
||||||
@@ -1534,14 +1439,6 @@ public class StructureUtility {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return BlocksToPlace.create(block, meta);
|
return BlocksToPlace.create(block, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if (item == null) return null;
|
|
||||||
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1584,14 +1481,6 @@ public class StructureUtility {
|
|||||||
// there is getSubItems on ItemBlock, but it's client only
|
// there is getSubItems on ItemBlock, but it's client only
|
||||||
return BlocksToPlace.create(defaultBlock, defaultMeta);
|
return BlocksToPlace.create(defaultBlock, defaultMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if (item == null) return null;
|
|
||||||
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return new IStructureElement<T>() {
|
return new IStructureElement<T>() {
|
||||||
@@ -1624,14 +1513,6 @@ public class StructureUtility {
|
|||||||
// there is getSubItems on ItemBlock, but it's client only
|
// there is getSubItems on ItemBlock, but it's client only
|
||||||
return BlocksToPlace.create(defaultBlock, defaultMeta);
|
return BlocksToPlace.create(defaultBlock, defaultMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if (item == null) return null;
|
|
||||||
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1895,71 +1776,6 @@ public class StructureUtility {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return element.getDescription(context);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wraps an element and overrides its description. Useful for providing human-readable names to elements whose
|
|
||||||
* underlying implementation doesn't provide a description (e.g. tiered block elements).
|
|
||||||
*
|
|
||||||
* @param description the description to use, or null to clear any existing description
|
|
||||||
* @param element the element to wrap
|
|
||||||
*/
|
|
||||||
public static <B extends IStructureElement<T>, T> IStructureElement<T> withDescription(
|
|
||||||
@Nullable List<String> description, B element) {
|
|
||||||
return new IStructureElement<T>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean check(T t, World world, int x, int y, int z) {
|
|
||||||
return element.check(t, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
|
||||||
return element.couldBeValid(t, world, x, y, z, trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
|
||||||
return element.placeBlock(t, world, x, y, z, trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
|
||||||
return element.spawnHint(t, world, x, y, z, trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
|
|
||||||
AutoPlaceEnvironment env) {
|
|
||||||
return element.getBlocksToPlace(t, world, x, y, z, trigger, env);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
|
||||||
IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
|
|
||||||
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
|
|
||||||
AutoPlaceEnvironment env) {
|
|
||||||
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2016,12 +1832,6 @@ public class StructureUtility {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return element.getDescription(context);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2030,11 +1840,11 @@ public class StructureUtility {
|
|||||||
/**
|
/**
|
||||||
* Enable this structure element only if given predicate returns true.
|
* Enable this structure element only if given predicate returns true.
|
||||||
* <p>
|
* <p>
|
||||||
* Return REJECT_CONTINUE when survival auto place if given predicate returns false.
|
* Return SKIP when survival auto place if given predicate returns false.
|
||||||
*/
|
*/
|
||||||
public static <T> IStructureElement<T> onlyIf(Predicate<? super T> predicate,
|
public static <T> IStructureElement<T> onlyIf(Predicate<? super T> predicate,
|
||||||
IStructureElement<? super T> downstream) {
|
IStructureElement<? super T> downstream) {
|
||||||
return onlyIf(predicate, downstream, PlaceResult.REJECT_CONTINUE);
|
return onlyIf(predicate, downstream, PlaceResult.SKIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2091,12 +1901,6 @@ public class StructureUtility {
|
|||||||
if (predicate.test(t)) return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
if (predicate.test(t)) return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
||||||
return placeResultWhenDisabled;
|
return placeResultWhenDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return downstream.getDescription(context);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2109,10 +1913,10 @@ public class StructureUtility {
|
|||||||
* using {@link #isAir()}. It will not attempt to capture any errors though, so next one will not be tried if
|
* using {@link #isAir()}. It will not attempt to capture any errors though, so next one will not be tried if
|
||||||
* previous one would crash.
|
* previous one would crash.
|
||||||
* <p>
|
* <p>
|
||||||
* (*): For survival auto place, it will: REJECT, if any structure element returns REJECT (and none returned ACCEPT,
|
* (*): For survival auto place, it will * REJECT, if all structure element REJECT * SKIP, if 1 or more structure
|
||||||
* STOP, ACCEPT_STOP, or SKIP); REJECT_CONTINUE, if all structure elements return REJECT_CONTINUE (none returned
|
* element SKIP and the rest structure element (0 or more) REJECT * any other result, **immediately** upon any
|
||||||
* REJECT); SKIP, as soon as any structure element returns SKIP; any other result, immediately upon any structure
|
* structure element returns these other results. This behavior is not 100% fixed and might change later on, but we
|
||||||
* element returning those.
|
* will send the notice on a best effort basis.
|
||||||
* <p>
|
* <p>
|
||||||
* Take care while chaining, as it will try to call every structure element until it returns true. If none does it
|
* Take care while chaining, as it will try to call every structure element until it returns true. If none does it
|
||||||
* will finally return false.
|
* will finally return false.
|
||||||
@@ -2194,12 +1998,6 @@ public class StructureUtility {
|
|||||||
AutoPlaceEnvironment env) {
|
AutoPlaceEnvironment env) {
|
||||||
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, env);
|
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return elem.getDescription(context.getCurrentContext());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
@@ -2809,7 +2607,7 @@ public class StructureUtility {
|
|||||||
if (keyExtractor == null || map == null) {
|
if (keyExtractor == null || map == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
return defer(keyExtractorCheck.andThen(map::get), keyExtractor.andThen(map::get));
|
return defer(keyExtractorCheck.andThen(map::get), keyExtractor.<IStructureElement<T>>andThen(map::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3037,12 +2835,6 @@ public class StructureUtility {
|
|||||||
warnNoExplicitSubChannel(env.getActor());
|
warnNoExplicitSubChannel(env.getActor());
|
||||||
return backing.survivalPlaceBlock(t, world, x, y, z, newTrigger, env);
|
return backing.survivalPlaceBlock(t, world, x, y, z, newTrigger, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public List<String> getDescription(T context) {
|
|
||||||
return backing.getDescription(context);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|||||||
@@ -43,10 +43,9 @@ class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
|||||||
env.offsetABC[2] = c;
|
env.offsetABC[2] = c;
|
||||||
env.setSource(params.getSource());
|
env.setSource(params.getSource());
|
||||||
PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, env);
|
PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, env);
|
||||||
if (placeResult != PlaceResult.SKIP && placeResult != PlaceResult.REJECT_CONTINUE && built == -1) built = 0;
|
if (placeResult != PlaceResult.SKIP && built == -1) built = 0;
|
||||||
switch (placeResult) {
|
switch (placeResult) {
|
||||||
case SKIP:
|
case SKIP:
|
||||||
case REJECT_CONTINUE:
|
|
||||||
return true;
|
return true;
|
||||||
case ACCEPT:
|
case ACCEPT:
|
||||||
if (check) element.check(object, world, x, y, z);
|
if (check) element.check(object, world, x, y, z);
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2022, glee8e This file is part of StructureLib.
|
||||||
|
* <p>
|
||||||
|
* StructureLib is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||||
|
* Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
* <p>
|
||||||
|
* StructureLib 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 Lesser General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License along with Foobar; if not, write to the Free
|
||||||
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
package com.gtnewhorizon.structurelib.util;
|
package com.gtnewhorizon.structurelib.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.util;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ItemStackArrayIterable implements Iterable<ItemStack> {
|
||||||
|
|
||||||
|
private final ItemStack[] stacks;
|
||||||
|
|
||||||
|
public ItemStackArrayIterable(ItemStack[] stacks) {
|
||||||
|
this.stacks = stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getStacks() {
|
||||||
|
return stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<ItemStack> iterator() {
|
||||||
|
return new Iterator<ItemStack>() {
|
||||||
|
|
||||||
|
private int ptr = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return ptr < stacks.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack next() {
|
||||||
|
return stacks[ptr++];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
stacks[ptr - 1] = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ public class MiscUtils {
|
|||||||
|
|
||||||
private MiscUtils() {}
|
private MiscUtils() {}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static Set<String> getTagKeys(NBTTagCompound tag) {
|
public static Set<String> getTagKeys(NBTTagCompound tag) {
|
||||||
return tag.func_150296_c();
|
return tag.func_150296_c();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,8 @@ public class Vec3Impl implements Comparable<Vec3Impl> {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
} else if (o instanceof Vec3Impl vec3i) {
|
} else if (o instanceof Vec3Impl) {
|
||||||
|
Vec3Impl vec3i = (Vec3Impl) o;
|
||||||
return val0 == vec3i.val0 && val1 == vec3i.val1 && val2 == vec3i.val2;
|
return val0 == vec3i.val0 && val1 == vec3i.val1 && val2 == vec3i.val2;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ structurelib.autoplace.error.not_enabled=§cThis multiblock does not support aut
|
|||||||
structurelib.autoplace.error.no_simple_block=§cSuggested to place §r%s§c but none was found
|
structurelib.autoplace.error.no_simple_block=§cSuggested to place §r%s§c but none was found
|
||||||
structurelib.autoplace.error.no_item_stack=§cSuggested to place block by using §r%s§c but none was found
|
structurelib.autoplace.error.no_item_stack=§cSuggested to place block by using §r%s§c but none was found
|
||||||
structurelib.autoplace.warning.no_explicit_channel=§6This structure depends on nonexistent sub channel §r%s§6. Using master channel instead.
|
structurelib.autoplace.warning.no_explicit_channel=§6This structure depends on nonexistent sub channel §r%s§6. Using master channel instead.
|
||||||
structurelib.autoplace.missing_block=§cMissing block: %s
|
|
||||||
|
|
||||||
structurelib.blockhint.desc.0=Helps while building
|
structurelib.blockhint.desc.0=Helps while building
|
||||||
structurelib.blockhint.0.name=Hint 1 dot
|
structurelib.blockhint.0.name=Hint 1 dot
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 176 B |
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 208 B |
|
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 184 B |
|
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 225 B |
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 133 B |
|
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 183 B |
|
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 197 B |
|
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 164 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 367 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 667 B |
|
Before Width: | Height: | Size: 361 B After Width: | Height: | Size: 439 B |
@@ -0,0 +1,102 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.coords;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.StructureUtility;
|
||||||
|
|
||||||
|
// spotless:off
|
||||||
|
class CoordinateTests {
|
||||||
|
|
||||||
|
private IStructureDefinition<?> getDefinition() {
|
||||||
|
String[][] main = {
|
||||||
|
{ " ", " ", " ", " ", " " },
|
||||||
|
{ " ", " ", " ", " ", " " },
|
||||||
|
{ " ", " ", " X ", " ", " " },
|
||||||
|
{ " ", " ", " YY ", " ", " " },
|
||||||
|
{ " ~ ", " ", " ", " ", " " }
|
||||||
|
};
|
||||||
|
|
||||||
|
return IStructureDefinition.builder()
|
||||||
|
.addShape("main", StructureUtility.transpose(main))
|
||||||
|
.addSocket('X', ' ')
|
||||||
|
.addSocket('Y', ' ')
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSocketAndCoordSystemTranslationToWorld() {
|
||||||
|
IStructureDefinition<?> def = getDefinition();
|
||||||
|
|
||||||
|
// Note: the position is the same object between all of these transforms, it is never copied, its generic just
|
||||||
|
// changes
|
||||||
|
|
||||||
|
var p = def.getSocket("main", 'X');
|
||||||
|
Assertions.assertEquals(new Position<>(2, 2, 2), p);
|
||||||
|
|
||||||
|
var p2 = def.getCoordinateSystem("main").translateInverse(p);
|
||||||
|
Assertions.assertEquals(new Position<>(0, -2, 2), p2);
|
||||||
|
|
||||||
|
var p3 = ExtendedFacing.NORTH_NORMAL_NONE.asCoordinateSystem().translateInverse(p2);
|
||||||
|
Assertions.assertEquals(new Position<>(0, 2, 2), p3);
|
||||||
|
|
||||||
|
var p4 = ControllerRelativeCoords.translateInverse(p3, 5, 5, 5);
|
||||||
|
Assertions.assertEquals(new Position<>(5, 7, 7), p4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSocketAndCoordSystemTranslationToStructureDef() {
|
||||||
|
IStructureDefinition<?> def = getDefinition();
|
||||||
|
|
||||||
|
// Note: the position is the same object between all of these transforms, it is never copied, its generic just
|
||||||
|
// changes
|
||||||
|
|
||||||
|
var p = new Position<WorldCoords>(5, 7, 7);
|
||||||
|
|
||||||
|
var p2 = ControllerRelativeCoords.translate(p, 5, 5, 5);
|
||||||
|
Assertions.assertEquals(new Position<>(0, 2, 2), p2);
|
||||||
|
|
||||||
|
var p3 = ExtendedFacing.NORTH_NORMAL_NONE.asCoordinateSystem().translate(p2);
|
||||||
|
Assertions.assertEquals(new Position<>(0, -2, 2), p3);
|
||||||
|
|
||||||
|
var p4 = def.getCoordinateSystem("main").translate(p3);
|
||||||
|
Assertions.assertEquals(new Position<>(2, 2, 2), p4);
|
||||||
|
|
||||||
|
Assertions.assertEquals(def.getSocket("main", 'X'), p4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSocketGetters() {
|
||||||
|
IStructureDefinition<?> def = getDefinition();
|
||||||
|
|
||||||
|
Assertions.assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> def.getSocket("invalid", 'X'));
|
||||||
|
Assertions.assertThrows(
|
||||||
|
IllegalStateException.class,
|
||||||
|
() -> def.getSocket("main", 'Y'));
|
||||||
|
Assertions.assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> def.getSocket("main", 'Z'));
|
||||||
|
|
||||||
|
Assertions.assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> def.getAllSockets("invalid", 'X'));
|
||||||
|
|
||||||
|
Assertions.assertEquals(
|
||||||
|
Collections.emptyList(),
|
||||||
|
def.getAllSockets("main", 'Z'));
|
||||||
|
Assertions.assertEquals(
|
||||||
|
Arrays.asList(new Position<>(2, 2, 2)),
|
||||||
|
def.getAllSockets("main", 'X'));
|
||||||
|
Assertions.assertEquals(
|
||||||
|
Arrays.asList(new Position<>(2, 3, 2), new Position<>(3, 3, 2)),
|
||||||
|
def.getAllSockets("main", 'Y'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// spotless:on
|
||||||