generated from tilera/1710mod
Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
7e5bb30b5b | |||
3711a234d0 | |||
43c7714469 | |||
a4fa45f169 | |||
b4ec3663bb | |||
de52e828b0 | |||
56a78cac1d | |||
45b12e39d7 | |||
763e47f565 | |||
882748522c | |||
b4bf13a4ab |
33 changed files with 2308 additions and 721 deletions
829
LICENSE
829
LICENSE
|
@ -1,674 +1,165 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
The GNU General Public License is a free, copyleft license for
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
software and other kinds of works.
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
0. Additional Definitions.
|
||||||
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
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
share and change all versions of a program--to make sure it remains free
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
General Public License.
|
||||||
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
|
"The Library" refers to a covered work governed by this License,
|
||||||
your programs, too.
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
An "Application" is any work that makes use of an interface provided
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
by the Library, but which is not otherwise based on the Library.
|
||||||
have the freedom to distribute copies of free software (and charge for
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
them if you wish), that you receive source code or can get it if you
|
of using an interface provided by the Library.
|
||||||
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.
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
To protect your rights, we need to prevent others from denying you
|
with which the Combined Work was made is also called the "Linked
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
Version".
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
For example, if you distribute copies of such a program, whether
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
based on the Application, and not on the Linked Version.
|
||||||
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
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
know their rights.
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
that there is no warranty for this free software. For both users' and
|
without being bound by section 3 of the GNU GPL.
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
2. Conveying Modified Versions.
|
||||||
authors of previous versions.
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
Some devices are designed to deny users access to install or run
|
facility refers to a function or data to be supplied by an Application
|
||||||
modified versions of the software inside them, although the manufacturer
|
that uses the facility (other than as an argument passed when the
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
facility is invoked), then you may convey a copy of the modified
|
||||||
protecting users' freedom to change the software. The systematic
|
version:
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
a) under this License, provided that you make a good faith effort to
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
ensure that, in the event an Application does not supply the
|
||||||
products. If such problems arise substantially in other domains, we
|
function or data, the facility still operates, and performs
|
||||||
stand ready to extend this provision to those domains in future versions
|
whatever part of its purpose remains meaningful, or
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
Finally, every program is threatened constantly by software patents.
|
this License applicable to that copy.
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
The object code form of an Application may incorporate material from
|
||||||
patents cannot be used to render the program non-free.
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
The precise terms and conditions for copying, distribution and
|
material is not limited to numerical parameters, data structure
|
||||||
modification follow.
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
0. Definitions.
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
document.
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
4. Combined Works.
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
You may convey a Combined Work under terms of your choice that,
|
||||||
"recipients" may be individuals or organizations.
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
engineering for debugging such modifications, if you also do each of
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
the following:
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
A "covered work" means either the unmodified Program or a work based
|
covered by this License.
|
||||||
on the Program.
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
To "propagate" a work means to do anything with it that, without
|
document.
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
c) For a Combined Work that displays copyright notices during
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
execution, include the copyright notice for the Library among
|
||||||
distribution (with or without modification), making available to the
|
these notices, as well as a reference directing the user to the
|
||||||
public, and in some countries other activities as well.
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
d) Do one of the following:
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
suitable for, and under terms that permit, the user to
|
||||||
to the extent that it includes a convenient and prominently visible
|
recombine or relink the Application with a modified version of
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
tells the user that there is no warranty for the work (except to the
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
extent that warranties are provided), that licensees may convey the
|
Corresponding Source.
|
||||||
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
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
menu, a prominent item in the list meets this criterion.
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
1. Source Code.
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
The "source code" for a work means the preferred form of the work
|
Version.
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
A "Standard Interface" means an interface that either is an official
|
GNU GPL, and only to the extent that such information is
|
||||||
standard defined by a recognized standards body, or, in the case of
|
necessary to install and execute a modified version of the
|
||||||
interfaces specified for a particular programming language, one that
|
Combined Work produced by recombining or relinking the
|
||||||
is widely used among developers working in that language.
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
The "System Libraries" of an executable work include anything, other
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
packaging a Major Component, but which is not part of that Major
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
Component, and (b) serves only to enable use of the work with that
|
for conveying Corresponding Source.)
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
5. Combined Libraries.
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
You may place library facilities that are a work based on the
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
Library side by side in a single library together with other library
|
||||||
produce the work, or an object code interpreter used to run it.
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
The "Corresponding Source" for a work in object code form means all
|
choice, if you do both of the following:
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
a) Accompany the combined library with a copy of the same work based
|
||||||
control those activities. However, it does not include the work's
|
on the Library, uncombined with any other library facilities,
|
||||||
System Libraries, or general-purpose tools or generally available free
|
conveyed under the terms of this License.
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
b) Give prominent notice with the combined library that part of it
|
||||||
includes interface definition files associated with source files for
|
is a work based on the Library, and explaining where to find the
|
||||||
the work, and the source code for shared libraries and dynamically
|
accompanying uncombined form of the same work.
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
The Corresponding Source need not include anything that users
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
can regenerate automatically from other parts of the Corresponding
|
versions will be similar in spirit to the present version, but may
|
||||||
Source.
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
Each version is given a distinguishing version number. If the
|
||||||
same work.
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
2. Basic Permissions.
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
All rights granted under this License are granted for the term of
|
published by the Free Software Foundation. If the Library as you
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
received it does not specify a version number of the GNU Lesser
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
permission to run the unmodified Program. The output from running a
|
General Public License ever published by the Free Software Foundation.
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
If the Library as you received it specifies that a proxy can decide
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
You may make, run and propagate covered works that you do not
|
permanent authorization for you to choose that version for the
|
||||||
convey, without conditions so long as your license otherwise remains
|
Library.
|
||||||
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>.
|
|
|
@ -10,4 +10,4 @@ This is a port of the 1.5.2 version of the universal electricity mod library for
|
||||||
- [MFFS](https://git.tilera.org/Anvilcraft/mffs)
|
- [MFFS](https://git.tilera.org/Anvilcraft/mffs)
|
||||||
- [ICBM](https://git.tilera.org/Anvilcraft/icbm)
|
- [ICBM](https://git.tilera.org/Anvilcraft/icbm)
|
||||||
- [Electric Expansion](https://git.tilera.org/Anvilcraft/electric-expansion)
|
- [Electric Expansion](https://git.tilera.org/Anvilcraft/electric-expansion)
|
||||||
- [Mekanism (tilera's fork)](https://git.tilera.org/tilera/Mekanism-1.7.10-Community-Edition)
|
- [Mekanism tilera Edition](https://git.tilera.org/tilera/Mekanism-tilera-Edition)
|
13
build.gradle
13
build.gradle
|
@ -23,7 +23,7 @@ apply plugin: 'maven-publish'
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
version = "5.1.1"
|
version = "5.2.2"
|
||||||
group= "universalelectricity"
|
group= "universalelectricity"
|
||||||
archivesBaseName = "universalelectricity"
|
archivesBaseName = "universalelectricity"
|
||||||
|
|
||||||
|
@ -37,16 +37,13 @@ minecraft {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "ic2"
|
url = "https://s3.tilera.xyz/cdn/minecraft/libs/"
|
||||||
url = "https://maven.ic2.player.to/"
|
metadataSources { artifact() }
|
||||||
metadataSources {
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'net.industrial-craft:industrialcraft-2:2.2.660-experimental:dev'
|
implementation "net.industrial-craft:industrialcraft-2:2.2.827-experimental:dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -94,4 +91,4 @@ publishing {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
163
src/main/java/com/jadarstudios/developercapes/DevCapes.java
Normal file
163
src/main/java/com/jadarstudios/developercapes/DevCapes.java
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.cape.CapeConfig;
|
||||||
|
import com.jadarstudios.developercapes.cape.CapeConfigManager;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DeveloperCapes is a library for Minecraft. It allows developers to quickly add capes
|
||||||
|
* for players they specify. DevCapes uses Minecraft Forge.
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class DevCapes {
|
||||||
|
private static DevCapes instance;
|
||||||
|
|
||||||
|
public static final Logger logger = LogManager.getLogger("DevCapes");
|
||||||
|
|
||||||
|
protected DevCapes() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DevCapes getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new DevCapes();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InputStream.close() needs to be called on this after you're done!
|
||||||
|
*
|
||||||
|
* @return {@link InputStream} for the {@link URL}
|
||||||
|
*/
|
||||||
|
public InputStream getStreamForURL(URL url) {
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
URLConnection connection = url.openConnection();
|
||||||
|
connection.setRequestProperty(
|
||||||
|
"User-Agent", System.getProperty("java.version")
|
||||||
|
);
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
is = connection.getInputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InputStream.close() needs to be called on this after you're done!
|
||||||
|
*
|
||||||
|
* @return {@link InputStream} for the {@link File}
|
||||||
|
*/
|
||||||
|
public InputStream getStreamForFile(File file) {
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
is = new FileInputStream(file);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/**
|
||||||
|
* DEPRECATED: Please use {@link #registerConfig(String jsonUrl)} instead.<p>
|
||||||
|
* Registers a config with DevCapes.
|
||||||
|
*
|
||||||
|
* @param jsonUrl
|
||||||
|
* The URL as a String that links to the Json file that you want
|
||||||
|
* to add
|
||||||
|
* @param identifier
|
||||||
|
* A unique Identifier, normally your mod id
|
||||||
|
* @return The id of the registered config
|
||||||
|
*/
|
||||||
|
public int registerConfig(String jsonURL, String identifier) {
|
||||||
|
return this.registerConfig(jsonURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a config with DevCapes.
|
||||||
|
*
|
||||||
|
* @param jsonUrl The URL as a String that links to the Json file that you want
|
||||||
|
* to add
|
||||||
|
* @return The id of the registered config
|
||||||
|
*/
|
||||||
|
public int registerConfig(String jsonUrl) {
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
URL url = new URL(jsonUrl);
|
||||||
|
id = this.registerConfig(url);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/**
|
||||||
|
* DEPRECATED: Please use {@link #registerConfig(URL url)} instead.<p>
|
||||||
|
* Registers a config with DevCapes.
|
||||||
|
*
|
||||||
|
* @param jsonUrl
|
||||||
|
* A {@link URL} that links to the Json file that you want to add
|
||||||
|
* @param identifier
|
||||||
|
* A unique Identifier, normally your mod id
|
||||||
|
* @return The id of the registered config
|
||||||
|
*/
|
||||||
|
public int registerConfig(URL url, String identifier) {
|
||||||
|
return this.registerConfig(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a config with DevCapes and returns the ID of the config.
|
||||||
|
*
|
||||||
|
* @param jsonUrl A {@link URL} that links to the Json file that you want to add
|
||||||
|
* @return The id of the registered config
|
||||||
|
*/
|
||||||
|
public int registerConfig(URL jsonUrl) {
|
||||||
|
int id = -1;
|
||||||
|
InputStream is = this.getStreamForURL(jsonUrl);
|
||||||
|
|
||||||
|
if (is == null) {
|
||||||
|
DevCapes.logger.error(String.format(
|
||||||
|
"Unable to establish a connection to the server, %s", jsonUrl.getHost()
|
||||||
|
));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
CapeConfig config = CapeConfigManager.getInstance().parse(is);
|
||||||
|
|
||||||
|
try {
|
||||||
|
id = CapeConfigManager.getUniqueId();
|
||||||
|
CapeConfigManager.getInstance().addConfig(id, config);
|
||||||
|
} catch (CapeConfigManager.InvalidCapeConfigIdException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
silentClose(is);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void silentClose(InputStream is) {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 3.3.0.0
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is an implementation of {@link IImageBuffer} that allows capes to be in HD
|
||||||
|
*
|
||||||
|
* @author Jadar
|
||||||
|
*/
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class HDImageBuffer implements IImageBuffer {
|
||||||
|
@Override
|
||||||
|
public BufferedImage parseUserSkin(final BufferedImage texture) {
|
||||||
|
if (texture == null)
|
||||||
|
return null;
|
||||||
|
int imageWidth = texture.getWidth(null) <= 64 ? 64 : texture.getWidth(null);
|
||||||
|
int imageHeight = texture.getHeight(null) <= 32 ? 32 : texture.getHeight(null);
|
||||||
|
|
||||||
|
BufferedImage capeImage = new BufferedImage(imageWidth, imageHeight, 2);
|
||||||
|
|
||||||
|
Graphics graphics = capeImage.getGraphics();
|
||||||
|
graphics.drawImage(texture, 0, 0, null);
|
||||||
|
graphics.dispose();
|
||||||
|
|
||||||
|
return capeImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void func_152634_a() {}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.cape.ICape;
|
||||||
|
import com.jadarstudios.developercapes.user.User;
|
||||||
|
import com.jadarstudios.developercapes.user.UserManager;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is not the class you are looking for.
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class RenderEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
|
||||||
|
AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
|
||||||
|
|
||||||
|
UserManager manager = UserManager.getInstance();
|
||||||
|
User user = manager.getUser(player.getUniqueID().toString());
|
||||||
|
if (user == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ICape cape = user.capes.get(0);
|
||||||
|
if (cape == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean flag = cape.isTextureLoaded(player);
|
||||||
|
if (!flag) {
|
||||||
|
cape.loadTexture(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Implementation of ICape used within Dev. Capes
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCape implements ICape {
|
||||||
|
protected String name;
|
||||||
|
protected ITextureObject texture;
|
||||||
|
protected ResourceLocation location;
|
||||||
|
|
||||||
|
public AbstractCape(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractCape() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextureObject getTexture() {
|
||||||
|
return this.texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation getLocation() {
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.user.Group;
|
||||||
|
import com.jadarstudios.developercapes.user.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The players that need to be outfitted are stored here
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class CapeConfig {
|
||||||
|
public HashMap<String, Group> groups;
|
||||||
|
public HashMap<String, User> users;
|
||||||
|
|
||||||
|
public CapeConfig() {
|
||||||
|
groups = new HashMap<String, Group>();
|
||||||
|
users = new HashMap<String, User>();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.google.common.primitives.UnsignedBytes;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import com.jadarstudios.developercapes.DevCapes;
|
||||||
|
import com.jadarstudios.developercapes.user.Group;
|
||||||
|
import com.jadarstudios.developercapes.user.GroupManager;
|
||||||
|
import com.jadarstudios.developercapes.user.User;
|
||||||
|
import com.jadarstudios.developercapes.user.UserManager;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All configs need a manager, this is it.
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class CapeConfigManager {
|
||||||
|
protected static CapeConfigManager instance;
|
||||||
|
|
||||||
|
protected static BitSet availableIds = new BitSet(256);
|
||||||
|
protected HashBiMap<Integer, CapeConfig> configs;
|
||||||
|
|
||||||
|
static {
|
||||||
|
availableIds.clear(availableIds.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CapeConfigManager() {
|
||||||
|
configs = HashBiMap.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CapeConfigManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CapeConfigManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConfig(int id, CapeConfig config) throws InvalidCapeConfigIdException {
|
||||||
|
int realId = claimId(id);
|
||||||
|
this.configs.put(realId, config);
|
||||||
|
addUsers(config.users);
|
||||||
|
addGroups(config.groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addUsers(Map<String, User> users) {
|
||||||
|
try {
|
||||||
|
UserManager.getInstance().addUsers(users.values());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addGroups(Map<String, Group> groups) {
|
||||||
|
try {
|
||||||
|
GroupManager.getInstance().addGroups(groups.values());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CapeConfig getConfig(int id) {
|
||||||
|
return this.configs.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIdForConfig(CapeConfig config) {
|
||||||
|
return this.configs.inverse().get(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getUniqueId() {
|
||||||
|
return availableIds.nextClearBit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int claimId(int id) throws InvalidCapeConfigIdException {
|
||||||
|
if (id <= 0) {
|
||||||
|
throw new InvalidCapeConfigIdException(
|
||||||
|
"The config ID must be a positive non-zero integer"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
UnsignedBytes.checkedCast(id);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isRegistered = availableIds.get(id);
|
||||||
|
if (isRegistered) {
|
||||||
|
throw new InvalidCapeConfigIdException(
|
||||||
|
String.format("The config ID %d is already claimed.", id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
availableIds.set(id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CapeConfig parse(InputStream is) {
|
||||||
|
if (is == null) {
|
||||||
|
throw new NullPointerException("Can not parse a null input stream!");
|
||||||
|
}
|
||||||
|
|
||||||
|
CapeConfig instance = new CapeConfig();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, Object> entries = new Gson().fromJson(isr, Map.class);
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> entry : entries.entrySet()) {
|
||||||
|
final String nodeName = entry.getKey();
|
||||||
|
final Object obj = entry.getValue();
|
||||||
|
if (obj instanceof Map) {
|
||||||
|
parseGroup(instance, nodeName, (Map) obj);
|
||||||
|
} else if (obj instanceof String) {
|
||||||
|
parseUser(instance, nodeName, (String) obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (JsonSyntaxException e) {
|
||||||
|
DevCapes.logger.error("CapeConfig could not be parsed because:");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void parseGroup(CapeConfig config, String node, Map group) {
|
||||||
|
Group g = GroupManager.getInstance().parse(node, group);
|
||||||
|
if (g != null) {
|
||||||
|
config.groups.put(g.name, g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void parseUser(CapeConfig config, String node, String user) {
|
||||||
|
User u = UserManager.getInstance().parse(node, user);
|
||||||
|
if (u != null) {
|
||||||
|
config.users.put(node, u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DEPRECATED! Please use {@link
|
||||||
|
* com.jadarstudios.developercapes.cape.CapeConfigManager#parse(java.io.InputStream
|
||||||
|
* is)} This will be removed in the next major release.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public CapeConfig parseFromStream(InputStream is) {
|
||||||
|
return this.parse(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InvalidCapeConfigIdException extends Exception {
|
||||||
|
public InvalidCapeConfigIdException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidCapeConfigIdException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidCapeConfigIdException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidCapeConfigIdException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.DevCapes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This manages all of the capes, be nice to it or you won't get one!
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class CapeManager {
|
||||||
|
protected static CapeManager instance;
|
||||||
|
|
||||||
|
private HashMap<String, ICape> capes;
|
||||||
|
|
||||||
|
public CapeManager() {
|
||||||
|
this.capes = new HashMap<String, ICape>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CapeManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CapeManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCape(ICape cape) {
|
||||||
|
if (!capes.containsValue(cape)) {
|
||||||
|
capes.put(cape.getName(), cape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCapes(Collection<ICape> capes) {
|
||||||
|
for (ICape c : capes) {
|
||||||
|
this.addCape(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICape getCape(String capeName) {
|
||||||
|
return capes.get(capeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICape newCape(String name) {
|
||||||
|
StaticCape cape = new StaticCape(name);
|
||||||
|
this.capes.put(name, cape);
|
||||||
|
return cape;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICape parse(String name, Object object) {
|
||||||
|
ICape cape = null;
|
||||||
|
if (object instanceof String || object instanceof URL) {
|
||||||
|
cape = parse(name, object.toString());
|
||||||
|
} else {
|
||||||
|
DevCapes.logger.error(String.format(
|
||||||
|
"Cape, %s, could not be parsed because it is not in an accepted format!",
|
||||||
|
object
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return cape;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICape parse(String name, String url) {
|
||||||
|
ICape cape = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
cape = new StaticCape(name, new URL(url));
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
DevCapes.logger.error(
|
||||||
|
String.format("Are you crazy?? \"%s\" is not a valid URL!", url)
|
||||||
|
);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return cape;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any class implementing this will be requested to act as a cape.
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public interface ICape {
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
public ITextureObject getTexture();
|
||||||
|
|
||||||
|
public ResourceLocation getLocation();
|
||||||
|
|
||||||
|
public void loadTexture(AbstractClientPlayer player);
|
||||||
|
|
||||||
|
public boolean isTextureLoaded(AbstractClientPlayer player);
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.cape;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.HDImageBuffer;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Cape implementation
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class StaticCape extends AbstractCape {
|
||||||
|
public StaticCape(String name, URL url) {
|
||||||
|
this.setName(name);
|
||||||
|
this.setURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StaticCape(String name) {
|
||||||
|
this(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadTexture(AbstractClientPlayer player) {
|
||||||
|
ResourceLocation location = this.getLocation();
|
||||||
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, location);
|
||||||
|
|
||||||
|
Minecraft.getMinecraft().renderEngine.loadTexture(location, this.getTexture());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTextureLoaded(AbstractClientPlayer player) {
|
||||||
|
ResourceLocation cape = player.getLocationCape();
|
||||||
|
return cape != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setURL(URL url) {
|
||||||
|
if (url == null) {
|
||||||
|
this.texture = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.texture = new ThreadDownloadImageData(
|
||||||
|
null, url.toString(), null, new HDImageBuffer()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.location = new ResourceLocation("DevCapes/" + name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.user;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.cape.ICape;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents a group of players that share a cape
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class Group {
|
||||||
|
protected HashMap<String, User> users;
|
||||||
|
protected ICape cape;
|
||||||
|
public final String name;
|
||||||
|
|
||||||
|
public Group(String name) {
|
||||||
|
this.users = new HashMap<String, User>();
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUser(User user) {
|
||||||
|
if (!this.users.containsValue(user)) {
|
||||||
|
user.capes.add(this.cape);
|
||||||
|
this.users.put(user.userUUID, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUsers(Set<User> users) {
|
||||||
|
for (User user : users) {
|
||||||
|
this.addUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeUser(User user) {
|
||||||
|
if (this.users.containsValue(user)) {
|
||||||
|
this.users.remove(user);
|
||||||
|
user.capes.remove(this.cape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICape getCape() {
|
||||||
|
return this.cape;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCape(ICape cape) {
|
||||||
|
for (User user : this.users.values()) {
|
||||||
|
user.capes.remove(this.cape);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cape = cape;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.user;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.DevCapes;
|
||||||
|
import com.jadarstudios.developercapes.cape.CapeManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All groups have to be managed
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class GroupManager {
|
||||||
|
protected static GroupManager instance;
|
||||||
|
|
||||||
|
private HashMap<String, Group> groups;
|
||||||
|
|
||||||
|
public GroupManager() {
|
||||||
|
this.groups = new HashMap<String, Group>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GroupManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new GroupManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGroup(Group group) {
|
||||||
|
groups.put(group.name, group);
|
||||||
|
|
||||||
|
try {
|
||||||
|
UserManager.getInstance().addUsers(group.users.values());
|
||||||
|
CapeManager.getInstance().addCape(group.cape);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGroups(Collection<Group> groups) {
|
||||||
|
for (Group g : groups) {
|
||||||
|
GroupManager.getInstance().addGroup(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group getGroup(String capeName) {
|
||||||
|
return groups.get(capeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group newGroup(String name) {
|
||||||
|
if (this.getGroup(name) != null) {
|
||||||
|
return this.getGroup(name);
|
||||||
|
}
|
||||||
|
Group group = new Group(name);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group parse(String name, Map<String, Object> data) {
|
||||||
|
Group group = new Group(name);
|
||||||
|
|
||||||
|
Object usersObj = data.get("users");
|
||||||
|
Object capeUrlObj = data.get("capeUrl");
|
||||||
|
|
||||||
|
if (!(usersObj instanceof ArrayList) || !(capeUrlObj instanceof String)) {
|
||||||
|
DevCapes.logger.error(String.format(
|
||||||
|
"Group %s could not be parsed because it either is invalid or missing elements.",
|
||||||
|
name
|
||||||
|
));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList users = (ArrayList) usersObj;
|
||||||
|
String capeUrl = (String) capeUrlObj;
|
||||||
|
|
||||||
|
group.cape = CapeManager.getInstance().parse(name, capeUrl);
|
||||||
|
|
||||||
|
for (Object obj : users) {
|
||||||
|
User user = UserManager.getInstance().parse((String) obj, group.cape);
|
||||||
|
if (user != null) {
|
||||||
|
group.addUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/com/jadarstudios/developercapes/user/User.java
Normal file
27
src/main/java/com/jadarstudios/developercapes/user/User.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.user;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.cape.ICape;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This player is getting their own cape
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class User {
|
||||||
|
public List<ICape> capes;
|
||||||
|
public final String userUUID;
|
||||||
|
|
||||||
|
public User(String userUUID) {
|
||||||
|
this.userUUID = userUUID;
|
||||||
|
this.capes = new ArrayList<ICape>();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/**
|
||||||
|
* DeveloperCapes by Jadar
|
||||||
|
* License: MIT License
|
||||||
|
* (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
|
||||||
|
* version 4.0.0.x
|
||||||
|
*/
|
||||||
|
package com.jadarstudios.developercapes.user;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.DevCapes;
|
||||||
|
import com.jadarstudios.developercapes.cape.CapeManager;
|
||||||
|
import com.jadarstudios.developercapes.cape.ICape;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users can not be trusted to put capes on by themselves
|
||||||
|
*
|
||||||
|
* @author jadar
|
||||||
|
*/
|
||||||
|
public class UserManager {
|
||||||
|
protected static UserManager instance;
|
||||||
|
|
||||||
|
protected HashMap<String, User> users;
|
||||||
|
|
||||||
|
public UserManager() {
|
||||||
|
this.users = new HashMap<String, User>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new UserManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser(String username) {
|
||||||
|
return this.users.get(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUser(User user) throws NullPointerException {
|
||||||
|
if (user == null || user.userUUID == null || user.userUUID.isEmpty()) {
|
||||||
|
throw new NullPointerException("Cannot add a null user!");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.users.put(user.userUUID, user);
|
||||||
|
CapeManager.getInstance().addCapes(user.capes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUsers(Collection<User> users) throws NullPointerException {
|
||||||
|
for (User u : users) {
|
||||||
|
this.addUser(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public User newUser(String username) {
|
||||||
|
User user = null;
|
||||||
|
if (this.users.containsKey(username)) {
|
||||||
|
user = this.getUser(username);
|
||||||
|
} else {
|
||||||
|
user = new User(username);
|
||||||
|
this.users.put(username, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User parse(String user, Object cape) {
|
||||||
|
User userInstance = new User(user);
|
||||||
|
|
||||||
|
ICape capeInstance = (cape instanceof ICape)
|
||||||
|
? (ICape) cape
|
||||||
|
: CapeManager.getInstance().parse(user, cape.toString());
|
||||||
|
|
||||||
|
if (capeInstance != null) {
|
||||||
|
userInstance.capes.add(capeInstance);
|
||||||
|
} else {
|
||||||
|
DevCapes.logger.error(String.format("Error parsing cape, %s", cape.toString())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return userInstance;
|
||||||
|
}
|
||||||
|
}
|
34
src/main/java/dev/tilera/capes/Capes.java
Normal file
34
src/main/java/dev/tilera/capes/Capes.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package dev.tilera.capes;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.DevCapes;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
|
public class Capes {
|
||||||
|
|
||||||
|
private static boolean capesInitialized = false;
|
||||||
|
|
||||||
|
public static void initCapes() {
|
||||||
|
if (!capesInitialized) {
|
||||||
|
capesInitialized = true;
|
||||||
|
try {
|
||||||
|
URL index = new URL("https://capes.tilera.xyz/devcapes/index");
|
||||||
|
InputStream stream = DevCapes.getInstance().getStreamForURL(index);
|
||||||
|
String capeConfig = IOUtils.toString(stream);
|
||||||
|
stream.close();
|
||||||
|
DevCapes.getInstance().registerConfig(
|
||||||
|
capeConfig
|
||||||
|
);
|
||||||
|
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.print("Cant load capes\n" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
src/main/java/dev/tilera/capes/RenderEventHandler.java
Normal file
31
src/main/java/dev/tilera/capes/RenderEventHandler.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package dev.tilera.capes;
|
||||||
|
|
||||||
|
import com.jadarstudios.developercapes.cape.ICape;
|
||||||
|
import com.jadarstudios.developercapes.user.User;
|
||||||
|
import com.jadarstudios.developercapes.user.UserManager;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
|
||||||
|
public class RenderEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
|
||||||
|
AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
|
||||||
|
|
||||||
|
UserManager manager = UserManager.getInstance();
|
||||||
|
User user = manager.getUser(player.getUniqueID().toString());
|
||||||
|
if (user == null) {
|
||||||
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICape cape = user.capes.get(0);
|
||||||
|
if (cape == null) {
|
||||||
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cape.loadTexture(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,19 @@ import cpw.mods.fml.common.Loader;
|
||||||
public enum CompatibilityType
|
public enum CompatibilityType
|
||||||
{
|
{
|
||||||
REDSTONE_FLUX("universalelectricity", "RedstoneFlux", "Redstone Flux", "RF", 2.5),
|
REDSTONE_FLUX("universalelectricity", "RedstoneFlux", "Redstone Flux", "RF", 2.5),
|
||||||
INDUSTRIALCRAFT("IC2", "IndustrialCraft", "Electrical Unit", "EU", 10);
|
INDUSTRIALCRAFT("IC2", "IndustrialCraft", "Electrical Unit", "EU", 10),
|
||||||
|
GREGTECH("gregtech", "GregTech", "Electrical Unit", "EU", 10),
|
||||||
|
HMB("hbm", "HBM", "HE", "HE", 10),
|
||||||
|
RAILCRAFT("railcraft", "Railcraft", "Charge", "C", 10),
|
||||||
|
MAGNETICRAFT("Magneticraft", "Magneticraft", "Watts", "W", 0.25),
|
||||||
|
APPENG("appliedenergistics2", "Applied Energistics 2", "Applied Energy", "AE", 5),
|
||||||
|
BLUETRICITY("universalelectricity", "Bluetricity", "Bluetricity", "BT", 17.5),
|
||||||
|
FACTORIZATION("factorization", "Factorization", "Charge", "C", 0.4375),
|
||||||
|
ULTRATECH("UltraTech", "Ultratech", "Quantum Power", "QP", 50),
|
||||||
|
ELN("Eln", "Electrical Age", "Watts", "W", 10.0/3.0),
|
||||||
|
HEXCRAFT("hexcraft", "HEXCraft", "HEX", "HEX", 0.78125),
|
||||||
|
GALACTICRAFT("galacticraftcore", "Galacticraft", "Galacticraft Joule", "gJ", 1.525);
|
||||||
|
|
||||||
|
|
||||||
public final String modID;
|
public final String modID;
|
||||||
public final String moduleName;
|
public final String moduleName;
|
||||||
|
|
13
src/main/java/universalelectricity/api/vector/IRotation.java
Normal file
13
src/main/java/universalelectricity/api/vector/IRotation.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package universalelectricity.api.vector;
|
||||||
|
|
||||||
|
/** Simple interface to define that an object has rotation
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman */
|
||||||
|
public interface IRotation
|
||||||
|
{
|
||||||
|
double yaw();
|
||||||
|
|
||||||
|
double pitch();
|
||||||
|
|
||||||
|
double roll();
|
||||||
|
}
|
11
src/main/java/universalelectricity/api/vector/IVector2.java
Normal file
11
src/main/java/universalelectricity/api/vector/IVector2.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package universalelectricity.api.vector;
|
||||||
|
|
||||||
|
/** Useful interface to define that an object has a 2D location.
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman */
|
||||||
|
public interface IVector2
|
||||||
|
{
|
||||||
|
double x();
|
||||||
|
|
||||||
|
double y();
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package universalelectricity.api.vector;
|
||||||
|
|
||||||
|
/** Useful interface to define that an object has a 3D location.
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman */
|
||||||
|
public interface IVector3 extends IVector2
|
||||||
|
{
|
||||||
|
double z();
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package universalelectricity.api.vector;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/** Useful interface to define that an object has a 3D location, and a defined world.
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman */
|
||||||
|
public interface IVectorWorld extends IVector3
|
||||||
|
{
|
||||||
|
World world();
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import universalelectricity.api.CompatibilityModule;
|
import universalelectricity.api.CompatibilityModule;
|
||||||
import universalelectricity.compat.ic2.IC2CompatModule;
|
import universalelectricity.compat.ic2.IC2CompatModule;
|
||||||
|
@ -17,7 +16,7 @@ public class CompatHandler {
|
||||||
|
|
||||||
public static void initCompatHandlers() {
|
public static void initCompatHandlers() {
|
||||||
FMLCommonHandler.instance().bus().register(new CompatTickHandler());
|
FMLCommonHandler.instance().bus().register(new CompatTickHandler());
|
||||||
if (Loader.isModLoaded("IC2") && UniversalElectricity.ic2Compat) {
|
if (UniversalElectricity.isIC2CompatActive()) {
|
||||||
CompatibilityModule.register(new IC2CompatModule());
|
CompatibilityModule.register(new IC2CompatModule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package universalelectricity.core;
|
||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import universalelectricity.api.CompatibilityType;
|
import universalelectricity.api.CompatibilityType;
|
||||||
import universalelectricity.compat.CompatHandler;
|
import universalelectricity.compat.CompatHandler;
|
||||||
|
import universalelectricity.core.proxy.CommonProxy;
|
||||||
|
|
||||||
@Mod(modid = "universalelectricity", name = "Universal Electricity", version = UniversalElectricity.VERSION)
|
@Mod(modid = "universalelectricity", name = "Universal Electricity", version = UniversalElectricity.VERSION)
|
||||||
public class UniversalElectricity {
|
public class UniversalElectricity {
|
||||||
|
@ -23,6 +25,8 @@ public class UniversalElectricity {
|
||||||
public static boolean isNetworkActive = true;
|
public static boolean isNetworkActive = true;
|
||||||
public static boolean ic2Compat = false;
|
public static boolean ic2Compat = false;
|
||||||
public static final Material machine = new Material(MapColor.ironColor);
|
public static final Material machine = new Material(MapColor.ironColor);
|
||||||
|
@SidedProxy(modId = "universalelectricity", serverSide = "universalelectricity.core.proxy.CommonProxy", clientSide = "universalelectricity.core.proxy.ClientProxy")
|
||||||
|
public static CommonProxy proxy;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
|
@ -36,7 +40,11 @@ public class UniversalElectricity {
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent e) {
|
public void init(FMLInitializationEvent e) {
|
||||||
CompatHandler.initCompatHandlers();
|
CompatHandler.initCompatHandlers();
|
||||||
|
proxy.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIC2CompatActive() {
|
||||||
|
return ic2Compat && Loader.isModLoaded("IC2");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package universalelectricity.core.proxy;
|
||||||
|
|
||||||
|
import dev.tilera.capes.Capes;
|
||||||
|
|
||||||
|
public class ClientProxy extends CommonProxy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
super.init();
|
||||||
|
Capes.initCapes();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package universalelectricity.core.proxy;
|
||||||
|
|
||||||
|
public class CommonProxy {
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
241
src/main/java/universalelectricity/core/vector/EulerAngle.java
Normal file
241
src/main/java/universalelectricity/core/vector/EulerAngle.java
Normal file
|
@ -0,0 +1,241 @@
|
||||||
|
package universalelectricity.core.vector;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import universalelectricity.api.vector.IRotation;
|
||||||
|
import universalelectricity.api.vector.IVector3;
|
||||||
|
|
||||||
|
/** The euler angles describing a 3D rotation. The rotation always in degrees.
|
||||||
|
*
|
||||||
|
* Note: The rotational system Minecraft uses is non-standard. The angles and vector calculations
|
||||||
|
* have been calibrated to match. DEFINITIONS:
|
||||||
|
*
|
||||||
|
* Yaw: 0 Degrees - Looking at NORTH 90 - Looking at WEST 180 - Looking at SOUTH 270 - Looking at
|
||||||
|
* EAST
|
||||||
|
*
|
||||||
|
* Pitch: 0 Degrees - Looking straight forward towards the horizon. 90 Degrees - Looking straight up
|
||||||
|
* to the sky. -90 Degrees - Looking straight down to the void.
|
||||||
|
*
|
||||||
|
* Make sure all models are use the Techne Model loader, they will naturally follow this rule.
|
||||||
|
*
|
||||||
|
* @author Calclavia */
|
||||||
|
public class EulerAngle implements IRotation, IVector3
|
||||||
|
{
|
||||||
|
/** Angles in degrees. */
|
||||||
|
public double yaw, pitch, roll;
|
||||||
|
|
||||||
|
public EulerAngle()
|
||||||
|
{
|
||||||
|
this(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle(ForgeDirection dir)
|
||||||
|
{
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
pitch = -90;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
pitch = 90;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
yaw = 0;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
yaw = 180;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
yaw = 90;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
// or 270 degrees
|
||||||
|
yaw = -90;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle(double yaw, double pitch, double roll)
|
||||||
|
{
|
||||||
|
this.yaw = yaw;
|
||||||
|
this.pitch = pitch;
|
||||||
|
this.roll = roll;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle(double[] angles)
|
||||||
|
{
|
||||||
|
this(angles[0], angles[1], angles[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle(EulerAngle angle)
|
||||||
|
{
|
||||||
|
this(angle.yaw(), angle.pitch(), angle.roll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle(double yaw, double pitch)
|
||||||
|
{
|
||||||
|
this(yaw, pitch, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double yaw()
|
||||||
|
{
|
||||||
|
return yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double pitch()
|
||||||
|
{
|
||||||
|
return pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double roll()
|
||||||
|
{
|
||||||
|
return roll;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double yawRadians()
|
||||||
|
{
|
||||||
|
return Math.toRadians(yaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double pitchRadians()
|
||||||
|
{
|
||||||
|
return Math.toRadians(pitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double rollRadians()
|
||||||
|
{
|
||||||
|
return Math.toRadians(roll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double x()
|
||||||
|
{
|
||||||
|
return -Math.sin(yawRadians()) * Math.cos(pitchRadians());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double y()
|
||||||
|
{
|
||||||
|
return Math.sin(pitchRadians());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double z()
|
||||||
|
{
|
||||||
|
return -Math.cos(yawRadians()) * Math.cos(pitchRadians());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double[] toArray()
|
||||||
|
{
|
||||||
|
return new double[] { yaw(), pitch(), roll() };
|
||||||
|
}
|
||||||
|
|
||||||
|
public double[] toRadianArray()
|
||||||
|
{
|
||||||
|
return new double[] { yawRadians(), pitchRadians(), rollRadians() };
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle set(int i, double value)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
yaw = value;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pitch = value;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
roll = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** gets the difference in degrees between the two angles */
|
||||||
|
public EulerAngle difference(EulerAngle other)
|
||||||
|
{
|
||||||
|
return new EulerAngle(yaw() - other.yaw(), pitch() - other.pitch(), roll() - other.roll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle absoluteDifference(EulerAngle other)
|
||||||
|
{
|
||||||
|
return new EulerAngle(getAngleDifference(yaw(), other.yaw()), getAngleDifference(pitch(), other.pitch()), getAngleDifference(roll(), other.roll()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWithin(EulerAngle other, double margin)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
if (absoluteDifference(other).toArray()[i] > margin)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getAngleDifference(double angleA, double angleB)
|
||||||
|
{
|
||||||
|
return Math.abs(angleA - angleB);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EulerAngle clone()
|
||||||
|
{
|
||||||
|
return new EulerAngle(this.yaw(), this.pitch(), this.roll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double clampAngleTo360(double var)
|
||||||
|
{
|
||||||
|
return clampAngle(var, -360, 360);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double clampAngleTo180(double var)
|
||||||
|
{
|
||||||
|
return clampAngle(var, -180, 180);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double clampAngle(double var, double min, double max)
|
||||||
|
{
|
||||||
|
while (var < min)
|
||||||
|
var += 360;
|
||||||
|
|
||||||
|
while (var > max)
|
||||||
|
var -= 360;
|
||||||
|
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
long x = Double.doubleToLongBits(yaw());
|
||||||
|
long y = Double.doubleToLongBits(pitch());
|
||||||
|
long z = Double.doubleToLongBits(roll());
|
||||||
|
int hash = (int) (x ^ (x >>> 32));
|
||||||
|
hash = 31 * hash + (int) (y ^ (y >>> 32));
|
||||||
|
hash = 31 * hash + (int) (z ^ (z >>> 32));
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (o instanceof EulerAngle)
|
||||||
|
{
|
||||||
|
EulerAngle angle = (EulerAngle) o;
|
||||||
|
return yaw() == angle.yaw() && pitch() == angle.pitch() && roll() == angle.roll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Angle [" + this.yaw() + "," + this.pitch() + "," + this.roll() + "]";
|
||||||
|
}
|
||||||
|
}
|
156
src/main/java/universalelectricity/core/vector/Quaternion.java
Normal file
156
src/main/java/universalelectricity/core/vector/Quaternion.java
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
package universalelectricity.core.vector;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.MathContext;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
public class Quaternion implements Cloneable
|
||||||
|
{
|
||||||
|
public double x;
|
||||||
|
public double y;
|
||||||
|
public double z;
|
||||||
|
public double s;
|
||||||
|
public static final double SQRT2 = Math.sqrt(2D);
|
||||||
|
|
||||||
|
public Quaternion()
|
||||||
|
{
|
||||||
|
s = 1;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion(Quaternion Quaternion)
|
||||||
|
{
|
||||||
|
x = Quaternion.x;
|
||||||
|
y = Quaternion.y;
|
||||||
|
z = Quaternion.z;
|
||||||
|
s = Quaternion.s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion(double d, double d1, double d2, double d3)
|
||||||
|
{
|
||||||
|
x = d1;
|
||||||
|
y = d2;
|
||||||
|
z = d3;
|
||||||
|
s = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion set(Quaternion Quaternion)
|
||||||
|
{
|
||||||
|
x = Quaternion.x;
|
||||||
|
y = Quaternion.y;
|
||||||
|
z = Quaternion.z;
|
||||||
|
s = Quaternion.s;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion set(double d, double d1, double d2, double d3)
|
||||||
|
{
|
||||||
|
x = d1;
|
||||||
|
y = d2;
|
||||||
|
z = d3;
|
||||||
|
s = d;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Quaternion aroundAxis(double ax, double ay, double az, double angle)
|
||||||
|
{
|
||||||
|
return new Quaternion().setAroundAxis(ax, ay, az, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Quaternion aroundAxis(Vector3 axis, double angle)
|
||||||
|
{
|
||||||
|
return aroundAxis(axis.x, axis.y, axis.z, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion setAroundAxis(double ax, double ay, double az, double angle)
|
||||||
|
{
|
||||||
|
angle *= 0.5;
|
||||||
|
double d4 = Math.sin(angle);
|
||||||
|
return set(Math.cos(angle), ax * d4, ay * d4, az * d4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion setAroundAxis(Vector3 axis, double angle)
|
||||||
|
{
|
||||||
|
return setAroundAxis(axis.x, axis.y, axis.z, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion multiply(Quaternion Quaternion)
|
||||||
|
{
|
||||||
|
double d = s * Quaternion.s - x * Quaternion.x - y * Quaternion.y - z * Quaternion.z;
|
||||||
|
double d1 = s * Quaternion.x + x * Quaternion.s - y * Quaternion.z + z * Quaternion.y;
|
||||||
|
double d2 = s * Quaternion.y + x * Quaternion.z + y * Quaternion.s - z * Quaternion.x;
|
||||||
|
double d3 = s * Quaternion.z - x * Quaternion.y + y * Quaternion.x + z * Quaternion.s;
|
||||||
|
s = d;
|
||||||
|
x = d1;
|
||||||
|
y = d2;
|
||||||
|
z = d3;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion rightMultiply(Quaternion Quaternion)
|
||||||
|
{
|
||||||
|
double d = s * Quaternion.s - x * Quaternion.x - y * Quaternion.y - z * Quaternion.z;
|
||||||
|
double d1 = s * Quaternion.x + x * Quaternion.s + y * Quaternion.z - z * Quaternion.y;
|
||||||
|
double d2 = s * Quaternion.y - x * Quaternion.z + y * Quaternion.s + z * Quaternion.x;
|
||||||
|
double d3 = s * Quaternion.z + x * Quaternion.y - y * Quaternion.x + z * Quaternion.s;
|
||||||
|
s = d;
|
||||||
|
x = d1;
|
||||||
|
y = d2;
|
||||||
|
z = d3;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double mag()
|
||||||
|
{
|
||||||
|
return Math.sqrt(x * x + y * y + z * z + s * s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion normalize()
|
||||||
|
{
|
||||||
|
double d = mag();
|
||||||
|
if (d != 0)
|
||||||
|
{
|
||||||
|
d = 1 / d;
|
||||||
|
x *= d;
|
||||||
|
y *= d;
|
||||||
|
z *= d;
|
||||||
|
s *= d;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion copy()
|
||||||
|
{
|
||||||
|
return new Quaternion(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(Vector3 vec)
|
||||||
|
{
|
||||||
|
double d = -x * vec.x - y * vec.y - z * vec.z;
|
||||||
|
double d1 = s * vec.x + y * vec.z - z * vec.y;
|
||||||
|
double d2 = s * vec.y - x * vec.z + z * vec.x;
|
||||||
|
double d3 = s * vec.z + x * vec.y - y * vec.x;
|
||||||
|
vec.x = d1 * s - d * x - d2 * z + d3 * y;
|
||||||
|
vec.y = d2 * s - d * y + d1 * z - d3 * x;
|
||||||
|
vec.z = d3 * s - d * z - d1 * y + d2 * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
MathContext cont = new MathContext(4, RoundingMode.HALF_UP);
|
||||||
|
return "Quaternion[" + new BigDecimal(s, cont) + ", " + new BigDecimal(x, cont) + ", " + new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rotation rotation()
|
||||||
|
{
|
||||||
|
return new Rotation(this);
|
||||||
|
}
|
||||||
|
}
|
48
src/main/java/universalelectricity/core/vector/Rotation.java
Normal file
48
src/main/java/universalelectricity/core/vector/Rotation.java
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package universalelectricity.core.vector;
|
||||||
|
|
||||||
|
public class Rotation
|
||||||
|
{
|
||||||
|
public double angle;
|
||||||
|
public Vector3 axis;
|
||||||
|
private Quaternion quat;
|
||||||
|
|
||||||
|
public Rotation(double angle, Vector3 axis)
|
||||||
|
{
|
||||||
|
this.angle = angle;
|
||||||
|
this.axis = axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rotation(double angle, double x, double y, double z)
|
||||||
|
{
|
||||||
|
this(angle, new Vector3(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rotation(Quaternion quat)
|
||||||
|
{
|
||||||
|
this.quat = quat;
|
||||||
|
|
||||||
|
angle = Math.acos(quat.s) * 2;
|
||||||
|
if (angle == 0)
|
||||||
|
{
|
||||||
|
axis = new Vector3(0, 1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double sa = Math.sin(angle * 0.5);
|
||||||
|
axis = new Vector3(quat.x / sa, quat.y / sa, quat.z / sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void apply(Vector3 vec)
|
||||||
|
{
|
||||||
|
if (quat == null)
|
||||||
|
quat = Quaternion.aroundAxis(axis, angle);
|
||||||
|
|
||||||
|
vec.rotate(quat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyN(Vector3 normal)
|
||||||
|
{
|
||||||
|
apply(normal);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,101 +1,112 @@
|
||||||
package universalelectricity.core.vector;
|
package universalelectricity.core.vector;
|
||||||
|
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import universalelectricity.api.vector.IVector2;
|
||||||
|
|
||||||
public class Vector2 implements Cloneable {
|
public class Vector2 implements Cloneable, IVector2 {
|
||||||
|
|
||||||
public double x;
|
public double x;
|
||||||
public double y;
|
public double y;
|
||||||
|
|
||||||
|
|
||||||
public Vector2() {
|
public Vector2() {
|
||||||
this(0.0D, 0.0D);
|
this(0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2(double x, double y) {
|
public Vector2(double x, double y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int intX() {
|
public int intX() {
|
||||||
return (int)Math.floor(this.x);
|
return (int)Math.floor(this.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int intY() {
|
public int intY() {
|
||||||
return (int)Math.floor(this.y);
|
return (int)Math.floor(this.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 clone() {
|
public Vector2 clone() {
|
||||||
return new Vector2(this.x, this.y);
|
return new Vector2(this.x, this.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double distance(Vector2 point1, Vector2 point2) {
|
public static double distance(Vector2 point1, Vector2 point2) {
|
||||||
double xDifference = point1.x - point2.x;
|
double xDifference = point1.x - point2.x;
|
||||||
double yDiference = point1.y - point2.y;
|
double yDiference = point1.y - point2.y;
|
||||||
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDiference * yDiference);
|
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDiference * yDiference);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double slope(Vector2 point1, Vector2 point2) {
|
public static double slope(Vector2 point1, Vector2 point2) {
|
||||||
double xDifference = point1.x - point2.x;
|
double xDifference = point1.x - point2.x;
|
||||||
double yDiference = point1.y - point2.y;
|
double yDiference = point1.y - point2.y;
|
||||||
return yDiference / xDifference;
|
return yDiference / xDifference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double distanceTo(Vector2 target) {
|
public double distanceTo(Vector2 target) {
|
||||||
double xDifference = this.x - target.x;
|
double xDifference = this.x - target.x;
|
||||||
double yDifference = this.y - target.y;
|
double yDifference = this.y - target.y;
|
||||||
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference);
|
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 add(Vector2 par1) {
|
public Vector2 add(Vector2 par1) {
|
||||||
this.x += par1.x;
|
this.x += par1.x;
|
||||||
this.y += par1.y;
|
this.y += par1.y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 add(double par1) {
|
public Vector2 add(double par1) {
|
||||||
this.x += par1;
|
this.x += par1;
|
||||||
this.y += par1;
|
this.y += par1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 invert() {
|
public Vector2 invert() {
|
||||||
this.multiply(-1.0D);
|
this.multiply(-1.0D);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 multiply(double amount) {
|
public Vector2 multiply(double amount) {
|
||||||
this.x *= amount;
|
this.x *= amount;
|
||||||
this.y *= amount;
|
this.y *= amount;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 round() {
|
public Vector2 round() {
|
||||||
return new Vector2((double)Math.round(this.x), (double)Math.round(this.y));
|
return new Vector2((double)Math.round(this.x), (double)Math.round(this.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 ceil() {
|
public Vector2 ceil() {
|
||||||
return new Vector2(Math.ceil(this.x), Math.ceil(this.y));
|
return new Vector2(Math.ceil(this.x), Math.ceil(this.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 floor() {
|
public Vector2 floor() {
|
||||||
return new Vector2(Math.floor(this.x), Math.floor(this.y));
|
return new Vector2(Math.floor(this.x), Math.floor(this.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return ("X:" + this.x + "Y:" + this.y).hashCode();
|
return ("X:" + this.x + "Y:" + this.y).hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if(!(o instanceof Vector2)) {
|
if(!(o instanceof Vector2)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Vector2 vector = (Vector2)o;
|
Vector2 vector = (Vector2)o;
|
||||||
return this.x == vector.x && this.y == vector.y;
|
return this.x == vector.x && this.y == vector.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Vector2 [" + this.x + "," + this.y + "]";
|
return "Vector2 [" + this.x + "," + this.y + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double x() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double y() {
|
||||||
|
return this.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,9 @@ import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import universalelectricity.api.vector.IVector3;
|
||||||
|
|
||||||
public class Vector3 implements Cloneable {
|
public class Vector3 implements Cloneable, IVector3 {
|
||||||
|
|
||||||
public double x;
|
public double x;
|
||||||
public double y;
|
public double y;
|
||||||
|
@ -68,6 +69,17 @@ public class Vector3 implements Cloneable {
|
||||||
this.z = (double)direction.offsetZ;
|
this.z = (double)direction.offsetZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3(double yaw, double pitch)
|
||||||
|
{
|
||||||
|
this(new EulerAngle(yaw, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3(IVector3 vec3) {
|
||||||
|
this.x = vec3.x();
|
||||||
|
this.y = vec3.y();
|
||||||
|
this.z = vec3.z();
|
||||||
|
}
|
||||||
|
|
||||||
public int intX() {
|
public int intX() {
|
||||||
return (int)Math.floor(this.x);
|
return (int)Math.floor(this.x);
|
||||||
}
|
}
|
||||||
|
@ -283,4 +295,394 @@ public class Vector3 implements Cloneable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Vector3 [" + this.x + "," + this.y + "," + this.z + "]";
|
return "Vector3 [" + this.x + "," + this.y + "," + this.z + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double x() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double y() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double z() {
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle toAngle()
|
||||||
|
{
|
||||||
|
return new EulerAngle(Math.toDegrees(Math.atan2(x, z)), Math.toDegrees(-Math.atan2(y, Math.hypot(z, x))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EulerAngle toAngle(IVector3 target)
|
||||||
|
{
|
||||||
|
return clone().difference(target).toAngle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 UP()
|
||||||
|
{
|
||||||
|
return new Vector3(0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 DOWN()
|
||||||
|
{
|
||||||
|
return new Vector3(0, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 NORTH()
|
||||||
|
{
|
||||||
|
return new Vector3(0, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 SOUTH()
|
||||||
|
{
|
||||||
|
return new Vector3(0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 WEST()
|
||||||
|
{
|
||||||
|
return new Vector3(-1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 EAST()
|
||||||
|
{
|
||||||
|
return new Vector3(1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 ZERO()
|
||||||
|
{
|
||||||
|
return new Vector3(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 CENTER()
|
||||||
|
{
|
||||||
|
return new Vector3(0.5, 0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 translate(ForgeDirection side, double amount)
|
||||||
|
{
|
||||||
|
return this.translate(new Vector3(side).scale(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 translate(ForgeDirection side)
|
||||||
|
{
|
||||||
|
return this.translate(side, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 translate(IVector3 addition)
|
||||||
|
{
|
||||||
|
this.x += addition.x();
|
||||||
|
this.y += addition.y();
|
||||||
|
this.z += addition.z();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 translate(double x, double y, double z)
|
||||||
|
{
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 translate(double addition)
|
||||||
|
{
|
||||||
|
this.x += addition;
|
||||||
|
this.y += addition;
|
||||||
|
this.z += addition;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 translate(Vector3 first, IVector3 second)
|
||||||
|
{
|
||||||
|
return first.clone().translate(second);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 translate(Vector3 translate, double addition)
|
||||||
|
{
|
||||||
|
return translate.clone().translate(addition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 scale(double amount)
|
||||||
|
{
|
||||||
|
this.x *= amount;
|
||||||
|
this.y *= amount;
|
||||||
|
this.z *= amount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 scale(double x, double y, double z)
|
||||||
|
{
|
||||||
|
this.x *= x;
|
||||||
|
this.y *= y;
|
||||||
|
this.z *= z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 scale(Vector3 amount)
|
||||||
|
{
|
||||||
|
this.x *= amount.x;
|
||||||
|
this.y *= amount.y;
|
||||||
|
this.z *= amount.z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 scale(Vector3 vec, double amount)
|
||||||
|
{
|
||||||
|
return vec.scale(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 scale(Vector3 vec, Vector3 amount)
|
||||||
|
{
|
||||||
|
return vec.scale(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 difference(IVector3 amount)
|
||||||
|
{
|
||||||
|
return this.translate(-amount.x(), -amount.y(), -amount.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 difference(double amount)
|
||||||
|
{
|
||||||
|
return this.translate(-amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 difference(double x, double y, double z)
|
||||||
|
{
|
||||||
|
this.x -= x;
|
||||||
|
this.y -= y;
|
||||||
|
this.z -= z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RayTrace Code, retrieved from MachineMuse.
|
||||||
|
*
|
||||||
|
* @author MachineMuse
|
||||||
|
*/
|
||||||
|
public MovingObjectPosition rayTrace(World world, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance)
|
||||||
|
{
|
||||||
|
Vector3 lookVector = new Vector3(rotationYaw, rotationPitch);
|
||||||
|
Vector3 reachPoint = this.clone().translate(lookVector.clone().scale(reachDistance));
|
||||||
|
return rayTrace(world, reachPoint, collisionFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTrace(World world, Vector3 reachPoint, boolean collisionFlag)
|
||||||
|
{
|
||||||
|
MovingObjectPosition pickedBlock = this.rayTraceBlocks(world, reachPoint.clone(), collisionFlag);
|
||||||
|
MovingObjectPosition pickedEntity = this.rayTraceEntities(world, reachPoint.clone());
|
||||||
|
|
||||||
|
if (pickedBlock == null)
|
||||||
|
{
|
||||||
|
return pickedEntity;
|
||||||
|
}
|
||||||
|
else if (pickedEntity == null)
|
||||||
|
{
|
||||||
|
return pickedBlock;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double dBlock = this.distanceTo(new Vector3(pickedBlock.hitVec));
|
||||||
|
double dEntity = this.distanceTo(new Vector3(pickedEntity.hitVec));
|
||||||
|
|
||||||
|
if (dEntity < dBlock)
|
||||||
|
{
|
||||||
|
return pickedEntity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pickedBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTrace(World world, boolean collisionFlag, double reachDistance)
|
||||||
|
{
|
||||||
|
return rayTrace(world, 0, 0, collisionFlag, reachDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceBlocks(World world, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance)
|
||||||
|
{
|
||||||
|
Vector3 lookVector = new Vector3(rotationYaw, rotationPitch);
|
||||||
|
Vector3 reachPoint = this.clone().translate(lookVector.clone().scale(reachDistance));
|
||||||
|
return rayTraceBlocks(world, reachPoint, collisionFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceBlocks(World world, Vector3 vec, boolean collisionFlag)
|
||||||
|
{
|
||||||
|
return world.rayTraceBlocks(this.toVec3(), vec.toVec3(), collisionFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public MovingObjectPosition rayTraceEntities(World world, float rotationYaw, float rotationPitch, boolean collisionFlag, double reachDistance)
|
||||||
|
{
|
||||||
|
return this.rayTraceEntities(world, rotationYaw, rotationPitch, reachDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceEntities(World world, float rotationYaw, float rotationPitch, double reachDistance)
|
||||||
|
{
|
||||||
|
return this.rayTraceEntities(world, new Vector3(rotationYaw, rotationPitch).scale(reachDistance));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does an entity raytrace.
|
||||||
|
*
|
||||||
|
* @param world - The world object.
|
||||||
|
* @param target - The rotation in terms of Vector3. Convert using
|
||||||
|
* getDeltaPositionFromRotation()
|
||||||
|
* @return The target hit.
|
||||||
|
*/
|
||||||
|
public MovingObjectPosition rayTraceEntities(World world, Vector3 target)
|
||||||
|
{
|
||||||
|
MovingObjectPosition pickedEntity = null;
|
||||||
|
Vec3 startingPosition = toVec3();
|
||||||
|
Vec3 look = target.toVec3();
|
||||||
|
double reachDistance = distanceTo(target);
|
||||||
|
//Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
|
||||||
|
|
||||||
|
double checkBorder = 1.1 * reachDistance;
|
||||||
|
AxisAlignedBB boxToScan = AxisAlignedBB.getBoundingBox(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Entity> entitiesInBounds = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
|
||||||
|
double closestEntity = reachDistance;
|
||||||
|
|
||||||
|
if (entitiesInBounds == null || entitiesInBounds.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (Entity possibleHits : entitiesInBounds)
|
||||||
|
{
|
||||||
|
if (possibleHits != null && possibleHits.canBeCollidedWith() && possibleHits.boundingBox != null)
|
||||||
|
{
|
||||||
|
float border = possibleHits.getCollisionBorderSize();
|
||||||
|
AxisAlignedBB aabb = possibleHits.boundingBox.expand(border, border, border);
|
||||||
|
MovingObjectPosition hitMOP = aabb.calculateIntercept(startingPosition, target.toVec3());
|
||||||
|
|
||||||
|
if (hitMOP != null)
|
||||||
|
{
|
||||||
|
if (aabb.isVecInside(startingPosition))
|
||||||
|
{
|
||||||
|
if (0.0D < closestEntity || closestEntity == 0.0D)
|
||||||
|
{
|
||||||
|
pickedEntity = new MovingObjectPosition(possibleHits);
|
||||||
|
if (pickedEntity != null)
|
||||||
|
{
|
||||||
|
pickedEntity.hitVec = hitMOP.hitVec;
|
||||||
|
closestEntity = 0.0D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double distance = startingPosition.distanceTo(hitMOP.hitVec);
|
||||||
|
|
||||||
|
if (distance < closestEntity || closestEntity == 0.0D)
|
||||||
|
{
|
||||||
|
pickedEntity = new MovingObjectPosition(possibleHits);
|
||||||
|
pickedEntity.hitVec = hitMOP.hitVec;
|
||||||
|
closestEntity = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pickedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceEntities(World world, Entity target)
|
||||||
|
{
|
||||||
|
return rayTraceEntities(world, new Vector3(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 rotate(float angle, Vector3 axis)
|
||||||
|
{
|
||||||
|
return translateMatrix(getRotationMatrix(angle), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double[] getRotationMatrix(float angle)
|
||||||
|
{
|
||||||
|
double[] matrix = new double[16];
|
||||||
|
Vector3 axis = this.clone().normalize();
|
||||||
|
double x = axis.x;
|
||||||
|
double y = axis.y;
|
||||||
|
double z = axis.z;
|
||||||
|
angle *= 0.0174532925D;
|
||||||
|
float cos = (float) Math.cos(angle);
|
||||||
|
float ocos = 1.0F - cos;
|
||||||
|
float sin = (float) Math.sin(angle);
|
||||||
|
matrix[0] = (x * x * ocos + cos);
|
||||||
|
matrix[1] = (y * x * ocos + z * sin);
|
||||||
|
matrix[2] = (x * z * ocos - y * sin);
|
||||||
|
matrix[4] = (x * y * ocos - z * sin);
|
||||||
|
matrix[5] = (y * y * ocos + cos);
|
||||||
|
matrix[6] = (y * z * ocos + x * sin);
|
||||||
|
matrix[8] = (x * z * ocos + y * sin);
|
||||||
|
matrix[9] = (y * z * ocos - x * sin);
|
||||||
|
matrix[10] = (z * z * ocos + cos);
|
||||||
|
matrix[15] = 1.0F;
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 translateMatrix(double[] matrix, Vector3 translation)
|
||||||
|
{
|
||||||
|
double x = translation.x * matrix[0] + translation.y * matrix[1] + translation.z * matrix[2] + matrix[3];
|
||||||
|
double y = translation.x * matrix[4] + translation.y * matrix[5] + translation.z * matrix[6] + matrix[7];
|
||||||
|
double z = translation.x * matrix[8] + translation.y * matrix[9] + translation.z * matrix[10] + matrix[11];
|
||||||
|
translation.x = x;
|
||||||
|
translation.y = y;
|
||||||
|
translation.z = z;
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void rotate(double yaw, double pitch, double roll)
|
||||||
|
{
|
||||||
|
rotate(new EulerAngle(yaw, roll));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rotates this Vector by a yaw, pitch and roll value. */
|
||||||
|
public void rotate(EulerAngle angle)
|
||||||
|
{
|
||||||
|
double yawRadians = angle.yawRadians();
|
||||||
|
double pitchRadians = angle.pitchRadians();
|
||||||
|
double rollRadians = angle.rollRadians();
|
||||||
|
|
||||||
|
double x = this.x;
|
||||||
|
double y = this.y;
|
||||||
|
double z = this.z;
|
||||||
|
|
||||||
|
this.x = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians));
|
||||||
|
this.z = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians));
|
||||||
|
this.y = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rotates a point by a yaw and pitch around the anchor 0,0 by a specific angle. */
|
||||||
|
public void rotate(double yaw, double pitch)
|
||||||
|
{
|
||||||
|
rotate(new EulerAngle(yaw, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(double yaw)
|
||||||
|
{
|
||||||
|
double yawRadians = Math.toRadians(yaw);
|
||||||
|
|
||||||
|
double x = this.x;
|
||||||
|
double z = this.z;
|
||||||
|
|
||||||
|
if (yaw != 0)
|
||||||
|
{
|
||||||
|
this.x = x * Math.cos(yawRadians) - z * Math.sin(yawRadians);
|
||||||
|
this.z = x * Math.sin(yawRadians) + z * Math.cos(yawRadians);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 rotate(Quaternion rotator)
|
||||||
|
{
|
||||||
|
rotator.rotate(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
159
src/main/java/universalelectricity/core/vector/VectorWorld.java
Normal file
159
src/main/java/universalelectricity/core/vector/VectorWorld.java
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
package universalelectricity.core.vector;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import universalelectricity.api.vector.IVector3;
|
||||||
|
import universalelectricity.api.vector.IVectorWorld;
|
||||||
|
|
||||||
|
public class VectorWorld extends Vector3 implements IVectorWorld
|
||||||
|
{
|
||||||
|
public World world;
|
||||||
|
|
||||||
|
public VectorWorld(World world, double x, double y, double z)
|
||||||
|
{
|
||||||
|
super(x, y, z);
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VectorWorld(IVectorWorld vectorWorld)
|
||||||
|
{
|
||||||
|
this(vectorWorld.world(), vectorWorld.x(), vectorWorld.y(), vectorWorld.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VectorWorld(Entity entity)
|
||||||
|
{
|
||||||
|
super(entity);
|
||||||
|
this.world = entity.worldObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VectorWorld(TileEntity tile)
|
||||||
|
{
|
||||||
|
super(tile);
|
||||||
|
this.world = tile.getWorldObj();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VectorWorld(World world, IVector3 v)
|
||||||
|
{
|
||||||
|
this.x = v.x();
|
||||||
|
this.y = v.y();
|
||||||
|
this.z = v.z();
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World world()
|
||||||
|
{
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VectorWorld translate(double x, double y, double z)
|
||||||
|
{
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VectorWorld clone()
|
||||||
|
{
|
||||||
|
return new VectorWorld(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
nbt.setInteger("d", this.world.provider.dimensionId);
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getBlock()
|
||||||
|
{
|
||||||
|
return super.getBlock(this.world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockMetadata()
|
||||||
|
{
|
||||||
|
return super.getBlockMetadata(this.world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntity getTileEntity()
|
||||||
|
{
|
||||||
|
// Ensure that the world object actually exists.
|
||||||
|
if (this.world != null)
|
||||||
|
{
|
||||||
|
return super.getTileEntity(this.world);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Block id, int metadata, int notify)
|
||||||
|
{
|
||||||
|
return super.setBlock(this.world, id, metadata, notify);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Block id, int metadata)
|
||||||
|
{
|
||||||
|
return this.setBlock(id, metadata, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Block id)
|
||||||
|
{
|
||||||
|
return this.setBlock(id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Entity> getEntitiesWithin(Class<? extends Entity> par1Class)
|
||||||
|
{
|
||||||
|
return super.getEntitiesWithin(this.world, par1Class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VectorWorld fromCenter(Entity e)
|
||||||
|
{
|
||||||
|
return new VectorWorld(e.worldObj, e.posX, e.posY - e.yOffset + e.height / 2, e.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VectorWorld fromCenter(TileEntity e)
|
||||||
|
{
|
||||||
|
return new VectorWorld(e.getWorldObj(), e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceEntities(VectorWorld target)
|
||||||
|
{
|
||||||
|
return super.rayTraceEntities(target.world(), target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceEntities(Entity target)
|
||||||
|
{
|
||||||
|
return super.rayTraceEntities(world, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovingObjectPosition rayTraceEntities(Vector3 target)
|
||||||
|
{
|
||||||
|
return super.rayTraceEntities(world, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (o instanceof VectorWorld)
|
||||||
|
{
|
||||||
|
return super.equals(o) && this.world == ((VectorWorld) o).world;
|
||||||
|
}
|
||||||
|
return super.equals(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "VectorWorld [" + this.x + "," + this.y + "," + this.z + "," + this.world + "]";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue