mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: b8020379c Extract Adventure Version into a variable, add reminder to update the linked JD on the homepage (#5422) Airplane Changes: f5fb02447 Temporarily revert patch 3c728a7a9 Oops, these 2 too 37a93e561 Your daily dose of 1-3% optimization patches bbd689a77 Remove useless check
3203 lines
163 KiB
Diff
3203 lines
163 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Paul Sauve <paul@technove.co>
|
|
Date: Sat, 31 Oct 2020 19:21:42 -0500
|
|
Subject: [PATCH] Airplane Server Changes
|
|
|
|
GNU GENERAL PUBLIC LICENSE
|
|
Version 3, 29 June 2007
|
|
|
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
Everyone is permitted to copy and distribute verbatim copies
|
|
of this license document, but changing it is not allowed.
|
|
|
|
Preamble
|
|
|
|
The GNU General Public License is a free, copyleft license for
|
|
software and other kinds of works.
|
|
|
|
The licenses for most software and other practical works are designed
|
|
to take away your freedom to share and change the works. By contrast,
|
|
the GNU General Public License is intended to guarantee your freedom to
|
|
share and change all versions of a program--to make sure it remains free
|
|
software for all its users. We, the Free Software Foundation, use the
|
|
GNU General Public License for most of our software; it applies also to
|
|
any other work released this way by its authors. You can apply it to
|
|
your programs, too.
|
|
|
|
When we speak of free software, we are referring to freedom, not
|
|
price. Our General Public Licenses are designed to make sure that you
|
|
have the freedom to distribute copies of free software (and charge for
|
|
them if you wish), that you receive source code or can get it if you
|
|
want it, that you can change the software or use pieces of it in new
|
|
free programs, and that you know you can do these things.
|
|
|
|
To protect your rights, we need to prevent others from denying you
|
|
these rights or asking you to surrender the rights. Therefore, you have
|
|
certain responsibilities if you distribute copies of the software, or if
|
|
you modify it: responsibilities to respect the freedom of others.
|
|
|
|
For example, if you distribute copies of such a program, whether
|
|
gratis or for a fee, you must pass on to the recipients the same
|
|
freedoms that you received. You must make sure that they, too, receive
|
|
or can get the source code. And you must show them these terms so they
|
|
know their rights.
|
|
|
|
Developers that use the GNU GPL protect your rights with two steps:
|
|
(1) assert copyright on the software, and (2) offer you this License
|
|
giving you legal permission to copy, distribute and/or modify it.
|
|
|
|
For the developers' and authors' protection, the GPL clearly explains
|
|
that there is no warranty for this free software. For both users' and
|
|
authors' sake, the GPL requires that modified versions be marked as
|
|
changed, so that their problems will not be attributed erroneously to
|
|
authors of previous versions.
|
|
|
|
Some devices are designed to deny users access to install or run
|
|
modified versions of the software inside them, although the manufacturer
|
|
can do so. This is fundamentally incompatible with the aim of
|
|
protecting users' freedom to change the software. The systematic
|
|
pattern of such abuse occurs in the area of products for individuals to
|
|
use, which is precisely where it is most unacceptable. Therefore, we
|
|
have designed this version of the GPL to prohibit the practice for those
|
|
products. If such problems arise substantially in other domains, we
|
|
stand ready to extend this provision to those domains in future versions
|
|
of the GPL, as needed to protect the freedom of users.
|
|
|
|
Finally, every program is threatened constantly by software patents.
|
|
States should not allow patents to restrict development and use of
|
|
software on general-purpose computers, but in those that do, we wish to
|
|
avoid the special danger that patents applied to a free program could
|
|
make it effectively proprietary. To prevent this, the GPL assures that
|
|
patents cannot be used to render the program non-free.
|
|
|
|
The precise terms and conditions for copying, distribution and
|
|
modification follow.
|
|
|
|
TERMS AND CONDITIONS
|
|
|
|
0. Definitions.
|
|
|
|
"This License" refers to version 3 of the GNU General Public License.
|
|
|
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
works, such as semiconductor masks.
|
|
|
|
"The Program" refers to any copyrightable work licensed under this
|
|
License. Each licensee is addressed as "you". "Licensees" and
|
|
"recipients" may be individuals or organizations.
|
|
|
|
To "modify" a work means to copy from or adapt all or part of the work
|
|
in a fashion requiring copyright permission, other than the making of an
|
|
exact copy. The resulting work is called a "modified version" of the
|
|
earlier work or a work "based on" the earlier work.
|
|
|
|
A "covered work" means either the unmodified Program or a work based
|
|
on the Program.
|
|
|
|
To "propagate" a work means to do anything with it that, without
|
|
permission, would make you directly or secondarily liable for
|
|
infringement under applicable copyright law, except executing it on a
|
|
computer or modifying a private copy. Propagation includes copying,
|
|
distribution (with or without modification), making available to the
|
|
public, and in some countries other activities as well.
|
|
|
|
To "convey" a work means any kind of propagation that enables other
|
|
parties to make or receive copies. Mere interaction with a user through
|
|
a computer network, with no transfer of a copy, is not conveying.
|
|
|
|
An interactive user interface displays "Appropriate Legal Notices"
|
|
to the extent that it includes a convenient and prominently visible
|
|
feature that (1) displays an appropriate copyright notice, and (2)
|
|
tells the user that there is no warranty for the work (except to the
|
|
extent that warranties are provided), that licensees may convey the
|
|
work under this License, and how to view a copy of this License. If
|
|
the interface presents a list of user commands or options, such as a
|
|
menu, a prominent item in the list meets this criterion.
|
|
|
|
1. Source Code.
|
|
|
|
The "source code" for a work means the preferred form of the work
|
|
for making modifications to it. "Object code" means any non-source
|
|
form of a work.
|
|
|
|
A "Standard Interface" means an interface that either is an official
|
|
standard defined by a recognized standards body, or, in the case of
|
|
interfaces specified for a particular programming language, one that
|
|
is widely used among developers working in that language.
|
|
|
|
The "System Libraries" of an executable work include anything, other
|
|
than the work as a whole, that (a) is included in the normal form of
|
|
packaging a Major Component, but which is not part of that Major
|
|
Component, and (b) serves only to enable use of the work with that
|
|
Major Component, or to implement a Standard Interface for which an
|
|
implementation is available to the public in source code form. A
|
|
"Major Component", in this context, means a major essential component
|
|
(kernel, window system, and so on) of the specific operating system
|
|
(if any) on which the executable work runs, or a compiler used to
|
|
produce the work, or an object code interpreter used to run it.
|
|
|
|
The "Corresponding Source" for a work in object code form means all
|
|
the source code needed to generate, install, and (for an executable
|
|
work) run the object code and to modify the work, including scripts to
|
|
control those activities. However, it does not include the work's
|
|
System Libraries, or general-purpose tools or generally available free
|
|
programs which are used unmodified in performing those activities but
|
|
which are not part of the work. For example, Corresponding Source
|
|
includes interface definition files associated with source files for
|
|
the work, and the source code for shared libraries and dynamically
|
|
linked subprograms that the work is specifically designed to require,
|
|
such as by intimate data communication or control flow between those
|
|
subprograms and other parts of the work.
|
|
|
|
The Corresponding Source need not include anything that users
|
|
can regenerate automatically from other parts of the Corresponding
|
|
Source.
|
|
|
|
The Corresponding Source for a work in source code form is that
|
|
same work.
|
|
|
|
2. Basic Permissions.
|
|
|
|
All rights granted under this License are granted for the term of
|
|
copyright on the Program, and are irrevocable provided the stated
|
|
conditions are met. This License explicitly affirms your unlimited
|
|
permission to run the unmodified Program. The output from running a
|
|
covered work is covered by this License only if the output, given its
|
|
content, constitutes a covered work. This License acknowledges your
|
|
rights of fair use or other equivalent, as provided by copyright law.
|
|
|
|
You may make, run and propagate covered works that you do not
|
|
convey, without conditions so long as your license otherwise remains
|
|
in force. You may convey covered works to others for the sole purpose
|
|
of having them make modifications exclusively for you, or provide you
|
|
with facilities for running those works, provided that you comply with
|
|
the terms of this License in conveying all material for which you do
|
|
not control copyright. Those thus making or running the covered works
|
|
for you must do so exclusively on your behalf, under your direction
|
|
and control, on terms that prohibit them from making any copies of
|
|
your copyrighted material outside their relationship with you.
|
|
|
|
Conveying under any other circumstances is permitted solely under
|
|
the conditions stated below. Sublicensing is not allowed; section 10
|
|
makes it unnecessary.
|
|
|
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
|
|
No covered work shall be deemed part of an effective technological
|
|
measure under any applicable law fulfilling obligations under article
|
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
similar laws prohibiting or restricting circumvention of such
|
|
measures.
|
|
|
|
When you convey a covered work, you waive any legal power to forbid
|
|
circumvention of technological measures to the extent such circumvention
|
|
is effected by exercising rights under this License with respect to
|
|
the covered work, and you disclaim any intention to limit operation or
|
|
modification of the work as a means of enforcing, against the work's
|
|
users, your or third parties' legal rights to forbid circumvention of
|
|
technological measures.
|
|
|
|
4. Conveying Verbatim Copies.
|
|
|
|
You may convey verbatim copies of the Program's source code as you
|
|
receive it, in any medium, provided that you conspicuously and
|
|
appropriately publish on each copy an appropriate copyright notice;
|
|
keep intact all notices stating that this License and any
|
|
non-permissive terms added in accord with section 7 apply to the code;
|
|
keep intact all notices of the absence of any warranty; and give all
|
|
recipients a copy of this License along with the Program.
|
|
|
|
You may charge any price or no price for each copy that you convey,
|
|
and you may offer support or warranty protection for a fee.
|
|
|
|
5. Conveying Modified Source Versions.
|
|
|
|
You may convey a work based on the Program, or the modifications to
|
|
produce it from the Program, in the form of source code under the
|
|
terms of section 4, provided that you also meet all of these conditions:
|
|
|
|
a) The work must carry prominent notices stating that you modified
|
|
it, and giving a relevant date.
|
|
|
|
b) The work must carry prominent notices stating that it is
|
|
released under this License and any conditions added under section
|
|
7. This requirement modifies the requirement in section 4 to
|
|
"keep intact all notices".
|
|
|
|
c) You must license the entire work, as a whole, under this
|
|
License to anyone who comes into possession of a copy. This
|
|
License will therefore apply, along with any applicable section 7
|
|
additional terms, to the whole of the work, and all its parts,
|
|
regardless of how they are packaged. This License gives no
|
|
permission to license the work in any other way, but it does not
|
|
invalidate such permission if you have separately received it.
|
|
|
|
d) If the work has interactive user interfaces, each must display
|
|
Appropriate Legal Notices; however, if the Program has interactive
|
|
interfaces that do not display Appropriate Legal Notices, your
|
|
work need not make them do so.
|
|
|
|
A compilation of a covered work with other separate and independent
|
|
works, which are not by their nature extensions of the covered work,
|
|
and which are not combined with it such as to form a larger program,
|
|
in or on a volume of a storage or distribution medium, is called an
|
|
"aggregate" if the compilation and its resulting copyright are not
|
|
used to limit the access or legal rights of the compilation's users
|
|
beyond what the individual works permit. Inclusion of a covered work
|
|
in an aggregate does not cause this License to apply to the other
|
|
parts of the aggregate.
|
|
|
|
6. Conveying Non-Source Forms.
|
|
|
|
You may convey a covered work in object code form under the terms
|
|
of sections 4 and 5, provided that you also convey the
|
|
machine-readable Corresponding Source under the terms of this License,
|
|
in one of these ways:
|
|
|
|
a) Convey the object code in, or embodied in, a physical product
|
|
(including a physical distribution medium), accompanied by the
|
|
Corresponding Source fixed on a durable physical medium
|
|
customarily used for software interchange.
|
|
|
|
b) Convey the object code in, or embodied in, a physical product
|
|
(including a physical distribution medium), accompanied by a
|
|
written offer, valid for at least three years and valid for as
|
|
long as you offer spare parts or customer support for that product
|
|
model, to give anyone who possesses the object code either (1) a
|
|
copy of the Corresponding Source for all the software in the
|
|
product that is covered by this License, on a durable physical
|
|
medium customarily used for software interchange, for a price no
|
|
more than your reasonable cost of physically performing this
|
|
conveying of source, or (2) access to copy the
|
|
Corresponding Source from a network server at no charge.
|
|
|
|
c) Convey individual copies of the object code with a copy of the
|
|
written offer to provide the Corresponding Source. This
|
|
alternative is allowed only occasionally and noncommercially, and
|
|
only if you received the object code with such an offer, in accord
|
|
with subsection 6b.
|
|
|
|
d) Convey the object code by offering access from a designated
|
|
place (gratis or for a charge), and offer equivalent access to the
|
|
Corresponding Source in the same way through the same place at no
|
|
further charge. You need not require recipients to copy the
|
|
Corresponding Source along with the object code. If the place to
|
|
copy the object code is a network server, the Corresponding Source
|
|
may be on a different server (operated by you or a third party)
|
|
that supports equivalent copying facilities, provided you maintain
|
|
clear directions next to the object code saying where to find the
|
|
Corresponding Source. Regardless of what server hosts the
|
|
Corresponding Source, you remain obligated to ensure that it is
|
|
available for as long as needed to satisfy these requirements.
|
|
|
|
e) Convey the object code using peer-to-peer transmission, provided
|
|
you inform other peers where the object code and Corresponding
|
|
Source of the work are being offered to the general public at no
|
|
charge under subsection 6d.
|
|
|
|
A separable portion of the object code, whose source code is excluded
|
|
from the Corresponding Source as a System Library, need not be
|
|
included in conveying the object code work.
|
|
|
|
A "User Product" is either (1) a "consumer product", which means any
|
|
tangible personal property which is normally used for personal, family,
|
|
or household purposes, or (2) anything designed or sold for incorporation
|
|
into a dwelling. In determining whether a product is a consumer product,
|
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
product received by a particular user, "normally used" refers to a
|
|
typical or common use of that class of product, regardless of the status
|
|
of the particular user or of the way in which the particular user
|
|
actually uses, or expects or is expected to use, the product. A product
|
|
is a consumer product regardless of whether the product has substantial
|
|
commercial, industrial or non-consumer uses, unless such uses represent
|
|
the only significant mode of use of the product.
|
|
|
|
"Installation Information" for a User Product means any methods,
|
|
procedures, authorization keys, or other information required to install
|
|
and execute modified versions of a covered work in that User Product from
|
|
a modified version of its Corresponding Source. The information must
|
|
suffice to ensure that the continued functioning of the modified object
|
|
code is in no case prevented or interfered with solely because
|
|
modification has been made.
|
|
|
|
If you convey an object code work under this section in, or with, or
|
|
specifically for use in, a User Product, and the conveying occurs as
|
|
part of a transaction in which the right of possession and use of the
|
|
User Product is transferred to the recipient in perpetuity or for a
|
|
fixed term (regardless of how the transaction is characterized), the
|
|
Corresponding Source conveyed under this section must be accompanied
|
|
by the Installation Information. But this requirement does not apply
|
|
if neither you nor any third party retains the ability to install
|
|
modified object code on the User Product (for example, the work has
|
|
been installed in ROM).
|
|
|
|
The requirement to provide Installation Information does not include a
|
|
requirement to continue to provide support service, warranty, or updates
|
|
for a work that has been modified or installed by the recipient, or for
|
|
the User Product in which it has been modified or installed. Access to a
|
|
network may be denied when the modification itself materially and
|
|
adversely affects the operation of the network or violates the rules and
|
|
protocols for communication across the network.
|
|
|
|
Corresponding Source conveyed, and Installation Information provided,
|
|
in accord with this section must be in a format that is publicly
|
|
documented (and with an implementation available to the public in
|
|
source code form), and must require no special password or key for
|
|
unpacking, reading or copying.
|
|
|
|
7. Additional Terms.
|
|
|
|
"Additional permissions" are terms that supplement the terms of this
|
|
License by making exceptions from one or more of its conditions.
|
|
Additional permissions that are applicable to the entire Program shall
|
|
be treated as though they were included in this License, to the extent
|
|
that they are valid under applicable law. If additional permissions
|
|
apply only to part of the Program, that part may be used separately
|
|
under those permissions, but the entire Program remains governed by
|
|
this License without regard to the additional permissions.
|
|
|
|
When you convey a copy of a covered work, you may at your option
|
|
remove any additional permissions from that copy, or from any part of
|
|
it. (Additional permissions may be written to require their own
|
|
removal in certain cases when you modify the work.) You may place
|
|
additional permissions on material, added by you to a covered work,
|
|
for which you have or can give appropriate copyright permission.
|
|
|
|
Notwithstanding any other provision of this License, for material you
|
|
add to a covered work, you may (if authorized by the copyright holders of
|
|
that material) supplement the terms of this License with terms:
|
|
|
|
a) Disclaiming warranty or limiting liability differently from the
|
|
terms of sections 15 and 16 of this License; or
|
|
|
|
b) Requiring preservation of specified reasonable legal notices or
|
|
author attributions in that material or in the Appropriate Legal
|
|
Notices displayed by works containing it; or
|
|
|
|
c) Prohibiting misrepresentation of the origin of that material, or
|
|
requiring that modified versions of such material be marked in
|
|
reasonable ways as different from the original version; or
|
|
|
|
d) Limiting the use for publicity purposes of names of licensors or
|
|
authors of the material; or
|
|
|
|
e) Declining to grant rights under trademark law for use of some
|
|
trade names, trademarks, or service marks; or
|
|
|
|
f) Requiring indemnification of licensors and authors of that
|
|
material by anyone who conveys the material (or modified versions of
|
|
it) with contractual assumptions of liability to the recipient, for
|
|
any liability that these contractual assumptions directly impose on
|
|
those licensors and authors.
|
|
|
|
All other non-permissive additional terms are considered "further
|
|
restrictions" within the meaning of section 10. If the Program as you
|
|
received it, or any part of it, contains a notice stating that it is
|
|
governed by this License along with a term that is a further
|
|
restriction, you may remove that term. If a license document contains
|
|
a further restriction but permits relicensing or conveying under this
|
|
License, you may add to a covered work material governed by the terms
|
|
of that license document, provided that the further restriction does
|
|
not survive such relicensing or conveying.
|
|
|
|
If you add terms to a covered work in accord with this section, you
|
|
must place, in the relevant source files, a statement of the
|
|
additional terms that apply to those files, or a notice indicating
|
|
where to find the applicable terms.
|
|
|
|
Additional terms, permissive or non-permissive, may be stated in the
|
|
form of a separately written license, or stated as exceptions;
|
|
the above requirements apply either way.
|
|
|
|
8. Termination.
|
|
|
|
You may not propagate or modify a covered work except as expressly
|
|
provided under this License. Any attempt otherwise to propagate or
|
|
modify it is void, and will automatically terminate your rights under
|
|
this License (including any patent licenses granted under the third
|
|
paragraph of section 11).
|
|
|
|
However, if you cease all violation of this License, then your
|
|
license from a particular copyright holder is reinstated (a)
|
|
provisionally, unless and until the copyright holder explicitly and
|
|
finally terminates your license, and (b) permanently, if the copyright
|
|
holder fails to notify you of the violation by some reasonable means
|
|
prior to 60 days after the cessation.
|
|
|
|
Moreover, your license from a particular copyright holder is
|
|
reinstated permanently if the copyright holder notifies you of the
|
|
violation by some reasonable means, this is the first time you have
|
|
received notice of violation of this License (for any work) from that
|
|
copyright holder, and you cure the violation prior to 30 days after
|
|
your receipt of the notice.
|
|
|
|
Termination of your rights under this section does not terminate the
|
|
licenses of parties who have received copies or rights from you under
|
|
this License. If your rights have been terminated and not permanently
|
|
reinstated, you do not qualify to receive new licenses for the same
|
|
material under section 10.
|
|
|
|
9. Acceptance Not Required for Having Copies.
|
|
|
|
You are not required to accept this License in order to receive or
|
|
run a copy of the Program. Ancillary propagation of a covered work
|
|
occurring solely as a consequence of using peer-to-peer transmission
|
|
to receive a copy likewise does not require acceptance. However,
|
|
nothing other than this License grants you permission to propagate or
|
|
modify any covered work. These actions infringe copyright if you do
|
|
not accept this License. Therefore, by modifying or propagating a
|
|
covered work, you indicate your acceptance of this License to do so.
|
|
|
|
10. Automatic Licensing of Downstream Recipients.
|
|
|
|
Each time you convey a covered work, the recipient automatically
|
|
receives a license from the original licensors, to run, modify and
|
|
propagate that work, subject to this License. You are not responsible
|
|
for enforcing compliance by third parties with this License.
|
|
|
|
An "entity transaction" is a transaction transferring control of an
|
|
organization, or substantially all assets of one, or subdividing an
|
|
organization, or merging organizations. If propagation of a covered
|
|
work results from an entity transaction, each party to that
|
|
transaction who receives a copy of the work also receives whatever
|
|
licenses to the work the party's predecessor in interest had or could
|
|
give under the previous paragraph, plus a right to possession of the
|
|
Corresponding Source of the work from the predecessor in interest, if
|
|
the predecessor has it or can get it with reasonable efforts.
|
|
|
|
You may not impose any further restrictions on the exercise of the
|
|
rights granted or affirmed under this License. For example, you may
|
|
not impose a license fee, royalty, or other charge for exercise of
|
|
rights granted under this License, and you may not initiate litigation
|
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
any patent claim is infringed by making, using, selling, offering for
|
|
sale, or importing the Program or any portion of it.
|
|
|
|
11. Patents.
|
|
|
|
A "contributor" is a copyright holder who authorizes use under this
|
|
License of the Program or a work on which the Program is based. The
|
|
work thus licensed is called the contributor's "contributor version".
|
|
|
|
A contributor's "essential patent claims" are all patent claims
|
|
owned or controlled by the contributor, whether already acquired or
|
|
hereafter acquired, that would be infringed by some manner, permitted
|
|
by this License, of making, using, or selling its contributor version,
|
|
but do not include claims that would be infringed only as a
|
|
consequence of further modification of the contributor version. For
|
|
purposes of this definition, "control" includes the right to grant
|
|
patent sublicenses in a manner consistent with the requirements of
|
|
this License.
|
|
|
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
patent license under the contributor's essential patent claims, to
|
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
propagate the contents of its contributor version.
|
|
|
|
In the following three paragraphs, a "patent license" is any express
|
|
agreement or commitment, however denominated, not to enforce a patent
|
|
(such as an express permission to practice a patent or covenant not to
|
|
sue for patent infringement). To "grant" such a patent license to a
|
|
party means to make such an agreement or commitment not to enforce a
|
|
patent against the party.
|
|
|
|
If you convey a covered work, knowingly relying on a patent license,
|
|
and the Corresponding Source of the work is not available for anyone
|
|
to copy, free of charge and under the terms of this License, through a
|
|
publicly available network server or other readily accessible means,
|
|
then you must either (1) cause the Corresponding Source to be so
|
|
available, or (2) arrange to deprive yourself of the benefit of the
|
|
patent license for this particular work, or (3) arrange, in a manner
|
|
consistent with the requirements of this License, to extend the patent
|
|
license to downstream recipients. "Knowingly relying" means you have
|
|
actual knowledge that, but for the patent license, your conveying the
|
|
covered work in a country, or your recipient's use of the covered work
|
|
in a country, would infringe one or more identifiable patents in that
|
|
country that you have reason to believe are valid.
|
|
|
|
If, pursuant to or in connection with a single transaction or
|
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
covered work, and grant a patent license to some of the parties
|
|
receiving the covered work authorizing them to use, propagate, modify
|
|
or convey a specific copy of the covered work, then the patent license
|
|
you grant is automatically extended to all recipients of the covered
|
|
work and works based on it.
|
|
|
|
A patent license is "discriminatory" if it does not include within
|
|
the scope of its coverage, prohibits the exercise of, or is
|
|
conditioned on the non-exercise of one or more of the rights that are
|
|
specifically granted under this License. You may not convey a covered
|
|
work if you are a party to an arrangement with a third party that is
|
|
in the business of distributing software, under which you make payment
|
|
to the third party based on the extent of your activity of conveying
|
|
the work, and under which the third party grants, to any of the
|
|
parties who would receive the covered work from you, a discriminatory
|
|
patent license (a) in connection with copies of the covered work
|
|
conveyed by you (or copies made from those copies), or (b) primarily
|
|
for and in connection with specific products or compilations that
|
|
contain the covered work, unless you entered into that arrangement,
|
|
or that patent license was granted, prior to 28 March 2007.
|
|
|
|
Nothing in this License shall be construed as excluding or limiting
|
|
any implied license or other defenses to infringement that may
|
|
otherwise be available to you under applicable patent law.
|
|
|
|
12. No Surrender of Others' Freedom.
|
|
|
|
If conditions are imposed on you (whether by court order, agreement or
|
|
otherwise) that contradict the conditions of this License, they do not
|
|
excuse you from the conditions of this License. If you cannot convey a
|
|
covered work so as to satisfy simultaneously your obligations under this
|
|
License and any other pertinent obligations, then as a consequence you may
|
|
not convey it at all. For example, if you agree to terms that obligate you
|
|
to collect a royalty for further conveying from those to whom you convey
|
|
the Program, the only way you could satisfy both those terms and this
|
|
License would be to refrain entirely from conveying the Program.
|
|
|
|
13. Use with the GNU Affero General Public License.
|
|
|
|
Notwithstanding any other provision of this License, you have
|
|
permission to link or combine any covered work with a work licensed
|
|
under version 3 of the GNU Affero General Public License into a single
|
|
combined work, and to convey the resulting work. The terms of this
|
|
License will continue to apply to the part which is the covered work,
|
|
but the special requirements of the GNU Affero General Public License,
|
|
section 13, concerning interaction through a network will apply to the
|
|
combination as such.
|
|
|
|
14. Revised Versions of this License.
|
|
|
|
The Free Software Foundation may publish revised and/or new versions of
|
|
the GNU General Public License from time to time. Such new versions will
|
|
be similar in spirit to the present version, but may differ in detail to
|
|
address new problems or concerns.
|
|
|
|
Each version is given a distinguishing version number. If the
|
|
Program specifies that a certain numbered version of the GNU General
|
|
Public License "or any later version" applies to it, you have the
|
|
option of following the terms and conditions either of that numbered
|
|
version or of any later version published by the Free Software
|
|
Foundation. If the Program does not specify a version number of the
|
|
GNU General Public License, you may choose any version ever published
|
|
by the Free Software Foundation.
|
|
|
|
If the Program specifies that a proxy can decide which future
|
|
versions of the GNU General Public License can be used, that proxy's
|
|
public statement of acceptance of a version permanently authorizes you
|
|
to choose that version for the Program.
|
|
|
|
Later license versions may give you additional or different
|
|
permissions. However, no additional obligations are imposed on any
|
|
author or copyright holder as a result of your choosing to follow a
|
|
later version.
|
|
|
|
15. Disclaimer of Warranty.
|
|
|
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
|
|
16. Limitation of Liability.
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
SUCH DAMAGES.
|
|
|
|
17. Interpretation of Sections 15 and 16.
|
|
|
|
If the disclaimer of warranty and limitation of liability provided
|
|
above cannot be given local legal effect according to their terms,
|
|
reviewing courts shall apply local law that most closely approximates
|
|
an absolute waiver of all civil liability in connection with the
|
|
Program, unless a warranty or assumption of liability accompanies a
|
|
copy of the Program in return for a fee.
|
|
|
|
END OF TERMS AND CONDITIONS
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
|
index de7da911833569c97b7f800a43ee7354d19677e2..c917f825378dd16a329105b4e7fcc8882755bc5a 100644
|
|
--- a/pom.xml
|
|
+++ b/pom.xml
|
|
@@ -39,8 +39,8 @@
|
|
|
|
<dependencies>
|
|
<dependency>
|
|
- <groupId>com.tuinity</groupId>
|
|
- <artifactId>tuinity-api</artifactId>
|
|
+ <groupId>gg.airplane</groupId>
|
|
+ <artifactId>airplane-api</artifactId>
|
|
<version>${project.version}</version>
|
|
<scope>compile</scope>
|
|
</dependency>
|
|
@@ -166,6 +166,20 @@
|
|
<version>1.1.0-SNAPSHOT</version>
|
|
<scope>compile</scope>
|
|
</dependency>
|
|
+ <!-- Airplane Config -->
|
|
+ <dependency>
|
|
+ <groupId>com.github.technove</groupId>
|
|
+ <artifactId>AIR</artifactId>
|
|
+ <version>fe3dbb4420</version>
|
|
+ <scope>compile</scope>
|
|
+ </dependency>
|
|
+ <!-- Airplane - Flare -->
|
|
+ <dependency>
|
|
+ <groupId>com.github.technove</groupId>
|
|
+ <artifactId>Flare</artifactId>
|
|
+ <version>master-SNAPSHOT</version>
|
|
+ <scope>compile</scope>
|
|
+ </dependency>
|
|
</dependencies>
|
|
|
|
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
|
|
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
index 52c0ab1ce46e1f3233ef746d9bc699356fa9fae4..b480bd3044370b8eb733166f0c4b737344475993 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
@@ -593,7 +593,7 @@ public class Metrics {
|
|
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
|
// Only start Metrics, if it's enabled in the config
|
|
if (config.getBoolean("enabled", true)) {
|
|
- Metrics metrics = new Metrics("Tuinity", serverUUID, logFailedRequests, Bukkit.getLogger()); // Tuinity - we have our own bstats page
|
|
+ Metrics metrics = new Metrics("Airplane", serverUUID, logFailedRequests, Bukkit.getLogger()); // Tuinity - we have our own bstats page // Airplane
|
|
|
|
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
|
String minecraftVersion = Bukkit.getVersion();
|
|
@@ -603,7 +603,7 @@ public class Metrics {
|
|
|
|
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
|
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() || PaperConfig.isProxyOnlineMode() ? "online" : "offline"));
|
|
- metrics.addCustomChart(new Metrics.SimplePie("tuinity_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Tuinity - we have our own bstats page
|
|
+ metrics.addCustomChart(new Metrics.SimplePie("airplane_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Tuinity - we have our own bstats page // Airplane
|
|
|
|
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
|
Map<String, Map<String, Integer>> map = new HashMap<>();
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index efc1e42d606e1c9feb1a4871c0714933ae92a1b2..14ac28d4d6b1ab0f0a70dfefc589f7723a1d2e1a 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -202,6 +202,15 @@ public class PaperConfig {
|
|
public static String timingsServerName;
|
|
private static void timings() {
|
|
boolean timings = getBoolean("timings.enabled", true);
|
|
+ // Airplane start
|
|
+ boolean reallyEnableTimings = getBoolean("timings.really-enabled", false);
|
|
+ if (timings && !reallyEnableTimings) {
|
|
+ Bukkit.getLogger().log(Level.WARNING, "[Airplane] To improve performance, timings have been disabled by default");
|
|
+ Bukkit.getLogger().log(Level.WARNING, "[Airplane] You can still use timings by using /timings on, but they will not start on server startup unless you set timings.really-enabled to true in paper.yml");
|
|
+ Bukkit.getLogger().log(Level.WARNING, "[Airplane] If you would like to disable this message, either set timings.really-enabled to true or timings.enabled to false.");
|
|
+ }
|
|
+ timings = reallyEnableTimings;
|
|
+ // Airplane end
|
|
boolean verboseTimings = getBoolean("timings.verbose", true);
|
|
TimingsManager.privacy = getBoolean("timings.server-name-privacy", false);
|
|
TimingsManager.hiddenConfigs = getList("timings.hidden-config-entries", Lists.newArrayList("database", "settings.bungeecord-addresses", "settings.velocity-support.secret"));
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
index 7063f1da3654b382e26b0093ad5d0ff04a2b38c2..b9c5479e5561f8fe68ea8f94fbf4e64de8a53bf9 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
@@ -28,8 +28,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
@Nonnull
|
|
@Override
|
|
public Component getVersionMessage(@Nonnull String serverVersion) {
|
|
- String[] parts = serverVersion.substring("git-Tuinity-".length()).split("[-\\s]"); // Tuinity
|
|
- final Component updateMessage = getUpdateStatusMessage("Spottedleaf/Tuinity", GITHUB_BRANCH_NAME, parts[0]); // Tuinity
|
|
+ String[] parts = serverVersion.substring("git-Airplane-".length()).split("[-\\s]"); // Tuinity
|
|
+ final Component updateMessage = getUpdateStatusMessage("TECHNOVE/Airplane", GITHUB_BRANCH_NAME, parts[0]); // Tuinity
|
|
final Component history = getHistory();
|
|
|
|
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
|
diff --git a/src/main/java/gg/airplane/AirplaneCommand.java b/src/main/java/gg/airplane/AirplaneCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..89c89e633f14b5820147e734b1b7ad8cadfdce80
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/AirplaneCommand.java
|
|
@@ -0,0 +1,65 @@
|
|
+package gg.airplane;
|
|
+
|
|
+import net.kyori.adventure.text.Component;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
+import net.md_5.bungee.api.ChatColor;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+
|
|
+import java.io.IOException;
|
|
+import java.util.Collections;
|
|
+import java.util.List;
|
|
+import java.util.stream.Collectors;
|
|
+import java.util.stream.Stream;
|
|
+
|
|
+public class AirplaneCommand extends Command {
|
|
+
|
|
+ public AirplaneCommand() {
|
|
+ super("airplane");
|
|
+ this.description = "Airplane related commands";
|
|
+ this.usageMessage = "/airplane [reload | version]";
|
|
+ this.setPermission("bukkit.command.airplane");
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
|
+ if (args.length == 1) {
|
|
+ return Stream.of("reload", "version")
|
|
+ .filter(arg -> arg.startsWith(args[0].toLowerCase()))
|
|
+ .collect(Collectors.toList());
|
|
+ }
|
|
+ return Collections.emptyList();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
+ if (!testPermission(sender)) return true;
|
|
+ String prefix = ChatColor.of("#6a7eda") + "" + ChatColor.BOLD + "Airplane ✈ " + ChatColor.of("#e8ebf9");
|
|
+
|
|
+ if (args.length != 1) {
|
|
+ sender.sendMessage(prefix + "Usage: " + usageMessage);
|
|
+ args = new String[]{"version"};
|
|
+ }
|
|
+
|
|
+ if (args[0].equalsIgnoreCase("reload")) {
|
|
+ MinecraftServer console = MinecraftServer.getServer();
|
|
+ try {
|
|
+ AirplaneConfig.load();
|
|
+ } catch (IOException e) {
|
|
+ sender.sendMessage(Component.text("Failed to reload.", NamedTextColor.RED));
|
|
+ e.printStackTrace();
|
|
+ return true;
|
|
+ }
|
|
+ console.server.reloadCount++;
|
|
+
|
|
+ Command.broadcastCommandMessage(sender, prefix + "Airplane configuration has been reloaded.");
|
|
+ } else if (args[0].equalsIgnoreCase("version")) {
|
|
+ Command.broadcastCommandMessage(sender, prefix + "This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
|
|
+ }
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/AirplaneConfig.java b/src/main/java/gg/airplane/AirplaneConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..65adf3ceda012c8cfdea675c40e2bb27d34ebac7
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/AirplaneConfig.java
|
|
@@ -0,0 +1,123 @@
|
|
+package gg.airplane;
|
|
+
|
|
+import co.technove.air.AIR;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.apache.logging.log4j.Level;
|
|
+
|
|
+import java.io.File;
|
|
+import java.io.FileInputStream;
|
|
+import java.io.FileOutputStream;
|
|
+import java.io.IOException;
|
|
+import java.lang.reflect.Method;
|
|
+import java.lang.reflect.Modifier;
|
|
+
|
|
+public class AirplaneConfig {
|
|
+
|
|
+ private static AIR config;
|
|
+
|
|
+ public static void load() throws IOException {
|
|
+ File configFile = new File("airplane.air");
|
|
+ if (configFile.exists()) {
|
|
+ try (FileInputStream inputStream = new FileInputStream(configFile)) {
|
|
+ config = new AIR(inputStream);
|
|
+ }
|
|
+ } else {
|
|
+ config = new AIR();
|
|
+ }
|
|
+
|
|
+ config.setComment("info",
|
|
+ "Airplane Configuration",
|
|
+ "Read https://blog.airplane.gg/ to find out more about Airplane",
|
|
+ "Join our Discord to receive support & optimization help: https://discord.gg/3gtc45q");
|
|
+ config.getString("info.version", "1.0");
|
|
+
|
|
+ for (Method method : AirplaneConfig.class.getDeclaredMethods()) {
|
|
+ if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers())) {
|
|
+ method.setAccessible(true);
|
|
+ try {
|
|
+ method.invoke(null);
|
|
+ } catch (Throwable t) {
|
|
+ MinecraftServer.LOGGER.log(Level.WARN, "Failed to load configuration option from " + method.getName(), t);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ try (FileOutputStream outputStream = new FileOutputStream(configFile)) {
|
|
+ config.save(outputStream);
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
+ public static int startDistance;
|
|
+ public static int startDistanceSquared;
|
|
+ public static int maximumActivationPrio;
|
|
+ public static int activationDistanceMod;
|
|
+ public static boolean dynamicVillagerBehavior;
|
|
+ public static boolean dynamicPiglinBehavior;
|
|
+ public static boolean dynamicHoglinBehavior;
|
|
+
|
|
+ private static void dynamicActivationRange() {
|
|
+ config.setComment("activation-range", "Optimizes how entities act when", "they're far away from the player");
|
|
+
|
|
+ startDistance = config.getInt("activation-range.start-distance", 12,
|
|
+ "This value determines how far away an entity has to be",
|
|
+ "from the player to start being effected by DEAR.");
|
|
+ startDistanceSquared = startDistance * startDistance;
|
|
+ maximumActivationPrio = config.getInt("activation-range.max-tick-freq", 20,
|
|
+ "This value defines how often in ticks, the furthest entity",
|
|
+ "will get their pathfinders and behaviors ticked. 20 = 1s");
|
|
+ activationDistanceMod = config.getInt("activation-range.activation-dist-mod", 8,
|
|
+ "This value defines how much distance modifies an entity's",
|
|
+ "tick frequency. freq = (distanceToPlayer^2) / (2^value)",
|
|
+ "If you want further away entities to tick less often, use 7.",
|
|
+ "If you want further away entities to tick more often, try 9.");
|
|
+
|
|
+ config.setComment("behavior-activation", "A list of entities to use the dynamic activation range", "to modify how often their behaviors are ticked");
|
|
+
|
|
+ dynamicVillagerBehavior = config.getBoolean("behavior-activation.villager", true);
|
|
+ dynamicPiglinBehavior = config.getBoolean("behavior-activation.piglin", true);
|
|
+ dynamicHoglinBehavior = config.getBoolean("behavior-activation.hoglin", true);
|
|
+ }
|
|
+
|
|
+
|
|
+ public static String profileWebUrl;
|
|
+
|
|
+ private static void profilerOptions() {
|
|
+ config.setComment("flare", "Configures Flare, the built-in profiler");
|
|
+
|
|
+ profileWebUrl = config.getString("flare.url", "https://flare.airplane.gg", "Sets the server to use for profiles.");
|
|
+ }
|
|
+
|
|
+
|
|
+ public static String accessToken;
|
|
+
|
|
+ private static void airplaneWebServices() {
|
|
+ config.setComment("web-services", "Options for connecting to Airplane's online utilities");
|
|
+
|
|
+ accessToken = config.getString("web-services.token", "");
|
|
+ // todo lookup token (off-thread) and let users know if their token is valid
|
|
+ if (accessToken.length() > 0) {
|
|
+ gg.airplane.flare.FlareSetup.init(); // Airplane
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
+ public static byte entityDespawnCheckFrequency;
|
|
+
|
|
+ private static void entitySettings() {
|
|
+ config.setComment("entities", "Configures settings for generic entities");
|
|
+
|
|
+ entityDespawnCheckFrequency = (byte) Math.max(config.getInt("entities.despawn-check-freq", 8), Byte.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+
|
|
+ public static boolean disableMethodProfiler;
|
|
+
|
|
+ private static void miscSettings() {
|
|
+ config.setComment("misc", "Settings for things that don't belong elsewhere");
|
|
+
|
|
+ disableMethodProfiler = config.getBoolean("misc.disable-method-profiler", true);
|
|
+ }
|
|
+
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/AirplaneLogger.java b/src/main/java/gg/airplane/AirplaneLogger.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..1a9d71739019d12772bec6076b195552ff6299f9
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/AirplaneLogger.java
|
|
@@ -0,0 +1,17 @@
|
|
+package gg.airplane;
|
|
+
|
|
+import org.bukkit.Bukkit;
|
|
+
|
|
+import java.util.logging.Level;
|
|
+import java.util.logging.Logger;
|
|
+
|
|
+public class AirplaneLogger extends Logger {
|
|
+ public static final AirplaneLogger LOGGER = new AirplaneLogger();
|
|
+
|
|
+ private AirplaneLogger() {
|
|
+ super("Airplane", null);
|
|
+
|
|
+ setParent(Bukkit.getLogger());
|
|
+ setLevel(Level.ALL);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/commands/AirplaneCommands.java b/src/main/java/gg/airplane/commands/AirplaneCommands.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..66b20250a26d005427601b1cdee43bdd9eba70cc
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/commands/AirplaneCommands.java
|
|
@@ -0,0 +1,12 @@
|
|
+package gg.airplane.commands;
|
|
+
|
|
+import gg.airplane.AirplaneCommand;
|
|
+import gg.airplane.flare.FlareCommand;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+
|
|
+public class AirplaneCommands {
|
|
+ public static void init() {
|
|
+ MinecraftServer.getServer().server.getCommandMap().register("airplane", "Airplane", new AirplaneCommand());
|
|
+ MinecraftServer.getServer().server.getCommandMap().register("flare", "Airplane", new FlareCommand());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/compat/ServerConfigurations.java b/src/main/java/gg/airplane/compat/ServerConfigurations.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..f4976428bc721319d2926e97cbe0f64c6e9e503c
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/compat/ServerConfigurations.java
|
|
@@ -0,0 +1,77 @@
|
|
+package gg.airplane.compat;
|
|
+
|
|
+import co.aikar.timings.TimingsManager;
|
|
+import com.google.common.io.Files;
|
|
+import org.bukkit.configuration.InvalidConfigurationException;
|
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
|
+
|
|
+import java.io.ByteArrayOutputStream;
|
|
+import java.io.File;
|
|
+import java.io.FileInputStream;
|
|
+import java.io.IOException;
|
|
+import java.nio.charset.StandardCharsets;
|
|
+import java.util.Arrays;
|
|
+import java.util.List;
|
|
+import java.util.Properties;
|
|
+import java.util.stream.Collectors;
|
|
+
|
|
+public class ServerConfigurations {
|
|
+
|
|
+ public static final String[] configurationFiles = new String[]{
|
|
+ "server.properties",
|
|
+ "bukkit.yml",
|
|
+ "spigot.yml",
|
|
+ "paper.yml",
|
|
+ "tuinity.yml",
|
|
+ "airplane.air"
|
|
+ };
|
|
+
|
|
+ public static String getCleanCopy(String configName) throws IOException {
|
|
+ File file = new File(configName);
|
|
+ List<String> hiddenConfigs = TimingsManager.hiddenConfigs;
|
|
+
|
|
+ if (configName.equals("airplane.air")) {
|
|
+ return Files.readLines(file, StandardCharsets.UTF_8)
|
|
+ .stream()
|
|
+ .filter(line -> !line.trim().startsWith("#"))
|
|
+ .map(line -> line.contains("token") ? " token = **" : line)
|
|
+ .collect(Collectors.joining("\n"));
|
|
+ }
|
|
+
|
|
+ switch (Files.getFileExtension(configName)) {
|
|
+ case "properties": {
|
|
+ Properties properties = new Properties();
|
|
+ try (FileInputStream inputStream = new FileInputStream(file)) {
|
|
+ properties.load(inputStream);
|
|
+ }
|
|
+ for (String hiddenConfig : hiddenConfigs) {
|
|
+ properties.remove(hiddenConfig);
|
|
+ }
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
+ properties.store(outputStream, "");
|
|
+ return Arrays.stream(outputStream.toString()
|
|
+ .split("\n"))
|
|
+ .filter(line -> !line.startsWith("#"))
|
|
+ .collect(Collectors.joining("\n"));
|
|
+ }
|
|
+ case "yml": {
|
|
+ YamlConfiguration configuration = new YamlConfiguration();
|
|
+ try {
|
|
+ configuration.load(file);
|
|
+ } catch (InvalidConfigurationException e) {
|
|
+ throw new IOException(e);
|
|
+ }
|
|
+ configuration.options().header(null);
|
|
+ for (String key : configuration.getKeys(true)) {
|
|
+ if (hiddenConfigs.contains(key)) {
|
|
+ configuration.set(key, null);
|
|
+ }
|
|
+ }
|
|
+ return configuration.saveToString();
|
|
+ }
|
|
+ default:
|
|
+ throw new IllegalArgumentException("Bad file type " + configName);
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/flare/FlareCommand.java b/src/main/java/gg/airplane/flare/FlareCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..ddc90f1589e683f452c5a74d9d2408803edea029
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/flare/FlareCommand.java
|
|
@@ -0,0 +1,149 @@
|
|
+package gg.airplane.flare;
|
|
+
|
|
+import com.google.common.collect.ImmutableList;
|
|
+import gg.airplane.AirplaneConfig;
|
|
+import gg.airplane.flare.exceptions.UserReportableException;
|
|
+import gg.airplane.flare.profiling.AsyncProfilerIntegration;
|
|
+import net.kyori.adventure.text.Component;
|
|
+import net.kyori.adventure.text.event.ClickEvent;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
+import net.kyori.adventure.text.format.TextColor;
|
|
+import net.kyori.adventure.text.format.TextDecoration;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.bukkit.command.ConsoleCommandSender;
|
|
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
|
+import org.bukkit.util.StringUtil;
|
|
+
|
|
+import java.util.ArrayList;
|
|
+import java.util.Collections;
|
|
+import java.util.List;
|
|
+
|
|
+public class FlareCommand extends Command {
|
|
+
|
|
+ private static final String BASE_URL = "https://blog.airplane.gg/flare-tutorial/#setting-the-access-token";
|
|
+ private static final TextColor HEX = TextColor.fromHexString("#e3eaea");
|
|
+ private static final Component PREFIX = Component.text()
|
|
+ .append(Component.text("Flare ✈")
|
|
+ .color(TextColor.fromHexString("#6a7eda"))
|
|
+ .decoration(TextDecoration.BOLD, true)
|
|
+ .append(Component.text(" ", HEX)
|
|
+ .decoration(TextDecoration.BOLD, false)))
|
|
+ .asComponent();
|
|
+
|
|
+ public FlareCommand() {
|
|
+ super("flare", "Profile your server with Flare", "/flare", Collections.singletonList("profile"));
|
|
+ this.setPermission("airplane.flare");
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
+ if (!testPermission(sender)) return true;
|
|
+ if (AirplaneConfig.accessToken.length() == 0) {
|
|
+ Component clickable = Component.text(BASE_URL, HEX, TextDecoration.UNDERLINED).clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, BASE_URL));
|
|
+
|
|
+ sender.sendMessage(PREFIX.append(Component.text("Flare currently requires an access token to use. To learn more, visit ").color(HEX).append(clickable)));
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ if (AsyncProfilerIntegration.doesNotSupportProfiling()) {
|
|
+ sender.sendMessage(PREFIX.append(
|
|
+ Component.text("Profiling is not supported in this environment, reason: " + AsyncProfilerIntegration.getDisabledReason(), NamedTextColor.RED)));
|
|
+ return true;
|
|
+ }
|
|
+ if (ProfilingManager.isProfiling()) {
|
|
+ if (args.length == 1 && args[0].equalsIgnoreCase("status")) {
|
|
+ sender.sendMessage(PREFIX.append(Component.text("Status: " + AsyncProfilerIntegration.status(), HEX)));
|
|
+ return true;
|
|
+ }
|
|
+ if (ProfilingManager.stop()) {
|
|
+ if (!(sender instanceof ConsoleCommandSender)) {
|
|
+ sender.sendMessage(PREFIX.append(Component.text("Profiling has been stopped.", HEX)));
|
|
+ }
|
|
+ } else {
|
|
+ sender.sendMessage(PREFIX.append(Component.text("Profiling has already been stopped.", HEX)));
|
|
+ }
|
|
+ } else {
|
|
+ ProfileType profileType = null;
|
|
+ if (args.length > 0) {
|
|
+ try {
|
|
+ profileType = ProfileType.valueOf(args[0].toUpperCase());
|
|
+ } catch (Exception e) {
|
|
+ sender.sendMessage(PREFIX.append(Component
|
|
+ .text("Invalid profile type ", HEX)
|
|
+ .append(Component.text(args[0], HEX, TextDecoration.BOLD)
|
|
+ .append(Component.text("!", HEX)))
|
|
+ ));
|
|
+ }
|
|
+ }
|
|
+ int interval = 5;
|
|
+ if (args.length > 1) {
|
|
+ try {
|
|
+ interval = Integer.parseInt(args[1]);
|
|
+ } catch (Exception e) {
|
|
+ sender.sendMessage(PREFIX.append(Component
|
|
+ .text("Invalid time in milliseconds ", HEX)
|
|
+ .append(Component.text(args[1], HEX, TextDecoration.BOLD)
|
|
+ .append(Component.text("!", HEX)))
|
|
+ ));
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ int finalInterval = interval;
|
|
+ ProfileType finalProfileType = profileType;
|
|
+ Bukkit.getScheduler().runTaskAsynchronously(new MinecraftInternalPlugin(), () -> {
|
|
+ try {
|
|
+ if (ProfilingManager.start(finalProfileType, finalInterval)) {
|
|
+ if (!(sender instanceof ConsoleCommandSender)) {
|
|
+ sender.sendMessage(PREFIX.append(Component
|
|
+ .text("Flare has been started: " + ProfilingManager.getProfilingUrl().get(), HEX)
|
|
+ .clickEvent(ClickEvent.openUrl(ProfilingManager.getProfilingUrl().get()))
|
|
+ ));
|
|
+ sender.sendMessage(PREFIX.append(Component.text(" Run /" + commandLabel + " to stop the Flare.", HEX)));
|
|
+ }
|
|
+ } else {
|
|
+ sender.sendMessage(PREFIX.append(Component
|
|
+ .text("Flare has already been started: " + ProfilingManager.getProfilingUrl().get(), HEX)
|
|
+ .clickEvent(ClickEvent.openUrl(ProfilingManager.getProfilingUrl().get()))
|
|
+ ));
|
|
+ }
|
|
+ } catch (UserReportableException e) {
|
|
+ sender.sendMessage(Component.text("Flare failed to start: " + e.getUserError(), NamedTextColor.RED));
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ });
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
|
+ if (AsyncProfilerIntegration.doesNotSupportProfiling()) {
|
|
+ return ImmutableList.of();
|
|
+ }
|
|
+
|
|
+ List<String> list = new ArrayList<>();
|
|
+ if (AsyncProfilerIntegration.isProfiling()) {
|
|
+ if (args.length == 1) {
|
|
+ String lastWord = args[0];
|
|
+ if (StringUtil.startsWithIgnoreCase("status", lastWord)) {
|
|
+ list.add("status");
|
|
+ }
|
|
+ if (StringUtil.startsWithIgnoreCase("stop", lastWord)) {
|
|
+ list.add("stop");
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ if (args.length <= 1) {
|
|
+ String lastWord = args.length == 0 ? "" : args[0];
|
|
+ for (ProfileType value : ProfileType.values()) {
|
|
+ if (StringUtil.startsWithIgnoreCase(value.getInternalName(), lastWord)) {
|
|
+ list.add(value.name().toLowerCase());
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return list;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/flare/FlareSetup.java b/src/main/java/gg/airplane/flare/FlareSetup.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..27ac32779e700494aeca8b425edb2871d3ec29cc
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/flare/FlareSetup.java
|
|
@@ -0,0 +1,146 @@
|
|
+package gg.airplane.flare;
|
|
+
|
|
+import com.google.common.cache.Cache;
|
|
+import com.google.common.cache.CacheBuilder;
|
|
+import gg.airplane.AirplaneConfig;
|
|
+import gg.airplane.AirplaneLogger;
|
|
+import gg.airplane.compat.ServerConfigurations;
|
|
+import gg.airplane.flare.profiling.AsyncProfilerIntegration;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
|
+import org.bukkit.plugin.Plugin;
|
|
+import org.bukkit.plugin.java.PluginClassLoader;
|
|
+import org.bukkit.scheduler.BukkitTask;
|
|
+
|
|
+import java.io.IOException;
|
|
+import java.util.HashMap;
|
|
+import java.util.LinkedHashMap;
|
|
+import java.util.Map;
|
|
+import java.util.concurrent.TimeUnit;
|
|
+import java.util.logging.Level;
|
|
+
|
|
+public class FlareSetup {
|
|
+
|
|
+ public static void init() {
|
|
+ ServerConnector.connector = new ServerConnector() {
|
|
+
|
|
+ private final Cache<String, String> pluginNameCache = CacheBuilder.newBuilder()
|
|
+ .expireAfterAccess(1, TimeUnit.MINUTES)
|
|
+ .maximumSize(1024)
|
|
+ .build();
|
|
+
|
|
+ @Override
|
|
+ public String getPluginForClass(String name) {
|
|
+ if (name.contains(".") && name.charAt(0) != '/') {
|
|
+ if (name.startsWith("net.minecraft") || name.startsWith("java.") || name.startsWith("com.mojang") || name.startsWith("com.google") || name.startsWith("it.unimi") || name.startsWith("sun")) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ String className = name.substring(0, name.lastIndexOf("."));
|
|
+ String existing = pluginNameCache.getIfPresent(name);
|
|
+ if (existing != null) {
|
|
+ return existing.isEmpty() ? null : existing;
|
|
+ }
|
|
+
|
|
+ String newValue = "";
|
|
+
|
|
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
|
+ ClassLoader classLoader = plugin.getClass().getClassLoader();
|
|
+ if (classLoader instanceof PluginClassLoader) {
|
|
+ try {
|
|
+ Class<?> aClass = ((PluginClassLoader) classLoader)._airplane_findClass(className);
|
|
+ if (aClass != null) {
|
|
+ newValue = plugin.getName();
|
|
+ }
|
|
+ } catch (ClassNotFoundException | IllegalAccessError e) {
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ pluginNameCache.put(name, newValue);
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Thread getMainThread() {
|
|
+ return MinecraftServer.getServer().serverThread;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Map<String, String> getConfigurations() {
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
+ for (String configurationFile : ServerConfigurations.configurationFiles) {
|
|
+ try {
|
|
+ map.put(configurationFile, ServerConfigurations.getCleanCopy(configurationFile));
|
|
+ } catch (IOException e) {
|
|
+ this.log(Level.WARNING, "Failed to load config file " + configurationFile, e);
|
|
+ }
|
|
+ }
|
|
+ return map;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void log(Level level, String s) {
|
|
+ AirplaneLogger.LOGGER.log(level, s);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void log(Level level, String s, Throwable throwable) {
|
|
+ AirplaneLogger.LOGGER.log(level, s, throwable);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getPrimaryVersion() {
|
|
+ return Bukkit.getVersion();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getApiVersion() {
|
|
+ return "bukkit:" + Bukkit.getBukkitVersion();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getMcVersion() {
|
|
+ return Bukkit.getMinecraftVersion();
|
|
+ }
|
|
+
|
|
+ private final Map<Runnable, BukkitTask> scheduledRunnables = new HashMap<>();
|
|
+
|
|
+ @Override
|
|
+ public void schedule(Runnable runnable, long l, long l1) {
|
|
+ BukkitTask task = Bukkit.getScheduler().runTaskTimer(new MinecraftInternalPlugin(), runnable, l, l1);
|
|
+ this.scheduledRunnables.put(runnable, task);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void scheduleAsync(Runnable runnable, long l, long l1) {
|
|
+ BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(new MinecraftInternalPlugin(), runnable, l, l1);
|
|
+ this.scheduledRunnables.put(runnable, task);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void cancel(Runnable runnable) {
|
|
+ this.scheduledRunnables.get(runnable).cancel();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void runAsync(Runnable runnable) {
|
|
+ Bukkit.getScheduler().runTaskAsynchronously(new MinecraftInternalPlugin(), runnable);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getWebUrl() {
|
|
+ return AirplaneConfig.profileWebUrl;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getToken() {
|
|
+ return AirplaneConfig.accessToken;
|
|
+ }
|
|
+ };
|
|
+ AsyncProfilerIntegration.init();
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/flare/ProfilingManager.java b/src/main/java/gg/airplane/flare/ProfilingManager.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..86d6650d174a7794a7ebe793cad033b42215c321
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/flare/ProfilingManager.java
|
|
@@ -0,0 +1,65 @@
|
|
+package gg.airplane.flare;
|
|
+
|
|
+import gg.airplane.AirplaneConfig;
|
|
+import gg.airplane.AirplaneLogger;
|
|
+import gg.airplane.flare.exceptions.UserReportableException;
|
|
+import gg.airplane.flare.profiling.ProfileController;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
|
+import org.bukkit.scheduler.BukkitTask;
|
|
+
|
|
+import javax.annotation.Nullable;
|
|
+import java.util.Optional;
|
|
+import java.util.logging.Level;
|
|
+
|
|
+public class ProfilingManager {
|
|
+
|
|
+ private static ProfileController currentController;
|
|
+ private static BukkitTask currentTask = null;
|
|
+
|
|
+ public static synchronized boolean isProfiling() {
|
|
+ return currentController != null;
|
|
+ }
|
|
+
|
|
+ public static synchronized Optional<String> getProfilingUrl() {
|
|
+ if (!isProfiling()) {
|
|
+ return Optional.empty();
|
|
+ }
|
|
+ return Optional.of(AirplaneConfig.profileWebUrl + "/" + currentController.getId());
|
|
+ }
|
|
+
|
|
+ public static synchronized boolean start(@Nullable ProfileType type, int interval) throws UserReportableException {
|
|
+ if (isProfiling()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (Bukkit.isPrimaryThread()) {
|
|
+ throw new UserReportableException("Profiles should be started off-thread");
|
|
+ }
|
|
+ currentController = new ProfileController(type, Math.max(interval, 1)); // don't allow lower than 20ms: https://bugzilla.redhat.com/show_bug.cgi?id=645528
|
|
+ currentTask = Bukkit.getScheduler().runTaskLater(new MinecraftInternalPlugin(), ProfilingManager::stop, 20 * 60 * 15);
|
|
+ AirplaneLogger.LOGGER.log(Level.INFO, "Flare has been started: " + getProfilingUrl().orElse("An error occurred retrieving the Flare URL."));
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ public static synchronized boolean stop() {
|
|
+ if (!isProfiling()) {
|
|
+ return false;
|
|
+ }
|
|
+ AirplaneLogger.LOGGER.log(Level.INFO, "Flare has been stopped: " + getProfilingUrl().orElse("An error occurred retrieving the Flare URL."));
|
|
+ try {
|
|
+ currentController.cancel();
|
|
+ } catch (Throwable t) {
|
|
+ AirplaneLogger.LOGGER.log(Level.WARNING, "Error occurred stopping Flare", t);
|
|
+ }
|
|
+ currentController = null;
|
|
+
|
|
+ try {
|
|
+ currentTask.cancel();
|
|
+ } catch (Throwable t) {
|
|
+ AirplaneLogger.LOGGER.log(Level.WARNING, "Error occurred stopping Flare", t);
|
|
+ }
|
|
+ currentTask = null;
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/gg/airplane/structs/FluidDirectionCache.java b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..11279fb136bbaf3e51d9b080a9e283d8ff0cbb47
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
|
@@ -0,0 +1,142 @@
|
|
+package gg.airplane.structs;
|
|
+
|
|
+import it.unimi.dsi.fastutil.HashCommon;
|
|
+
|
|
+/**
|
|
+ * This is a replacement for the cache used in FluidTypeFlowing.
|
|
+ * The requirements for the previous cache were:
|
|
+ * - Store 200 entries
|
|
+ * - Look for the flag in the cache
|
|
+ * - If it exists, move to front of cache
|
|
+ * - If it doesn't exist, remove last entry in cache and insert in front
|
|
+ *
|
|
+ * This class accomplishes something similar, however has a few different
|
|
+ * requirements put into place to make this more optimize:
|
|
+ *
|
|
+ * - maxDistance is the most amount of entries to be checked, instead
|
|
+ * of having to check the entire list.
|
|
+ * - In combination with that, entries are all tracked by age and how
|
|
+ * frequently they're used. This enables us to remove old entries,
|
|
+ * without constantly shifting any around.
|
|
+ *
|
|
+ * Usage of the previous map would have to reset the head every single usage,
|
|
+ * shifting the entire map. Here, nothing happens except an increment when
|
|
+ * the cache is hit, and when it needs to replace an old element only a single
|
|
+ * element is modified.
|
|
+ */
|
|
+public class FluidDirectionCache<T> {
|
|
+
|
|
+ private static class FluidDirectionEntry<T> {
|
|
+ private final T data;
|
|
+ private final boolean flag;
|
|
+ private short uses = 0;
|
|
+ private short age = 0;
|
|
+
|
|
+ private FluidDirectionEntry(T data, boolean flag) {
|
|
+ this.data = data;
|
|
+ this.flag = flag;
|
|
+ }
|
|
+
|
|
+ public int getValue() {
|
|
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
|
+ }
|
|
+
|
|
+ public void incrementUses() {
|
|
+ if (this.uses < Short.MAX_VALUE) {
|
|
+ this.uses++;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void incrementAge() {
|
|
+ if (this.age < Short.MAX_VALUE) {
|
|
+ this.age++;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private final FluidDirectionEntry[] entries;
|
|
+ private final int mask;
|
|
+ private final int maxDistance; // the most amount of entries to check for a value
|
|
+
|
|
+ public FluidDirectionCache(int size) {
|
|
+ float fill = 0.75f;
|
|
+
|
|
+ int arraySize = HashCommon.arraySize(size, fill);
|
|
+ this.entries = new FluidDirectionEntry[arraySize];
|
|
+ this.mask = arraySize - 1;
|
|
+ this.maxDistance = Math.max(4, arraySize >> 4);
|
|
+ }
|
|
+
|
|
+ public Boolean getValue(T data) {
|
|
+ FluidDirectionEntry curr;
|
|
+ int pos;
|
|
+
|
|
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
|
+ return null;
|
|
+ } else if (data.equals(curr.data)) {
|
|
+ curr.incrementUses();
|
|
+ return curr.flag;
|
|
+ }
|
|
+
|
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
|
+
|
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
|
+ if (data.equals(curr.data)) {
|
|
+ curr.incrementUses();
|
|
+ return curr.flag;
|
|
+ } else if (++checked >= this.maxDistance) {
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public void putValue(T data, boolean flag) {
|
|
+ FluidDirectionEntry<T> curr;
|
|
+ int pos;
|
|
+
|
|
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
|
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
|
+ return;
|
|
+ } else if (data.equals(curr.data)) {
|
|
+ curr.incrementUses();
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ int checked = 1; // start at 1 because we already checked the first spot above
|
|
+
|
|
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
|
+ if (data.equals(curr.data)) {
|
|
+ curr.incrementUses();
|
|
+ return;
|
|
+ } else if (++checked >= this.maxDistance) {
|
|
+ this.forceAdd(data, flag);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
|
+ }
|
|
+
|
|
+ private void forceAdd(T data, boolean flag) {
|
|
+ int expectedPos = HashCommon.mix(data.hashCode()) & this.mask;
|
|
+
|
|
+ int toRemovePos = expectedPos;
|
|
+ FluidDirectionEntry<T> entryToRemove = this.entries[toRemovePos];
|
|
+
|
|
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
|
+ int pos = i & this.mask;
|
|
+ FluidDirectionEntry<T> entry = this.entries[pos];
|
|
+ if (entry.getValue() < entryToRemove.getValue()) {
|
|
+ toRemovePos = pos;
|
|
+ entryToRemove = entry;
|
|
+ }
|
|
+
|
|
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
|
+ }
|
|
+
|
|
+ // remove the least used/oldest entry
|
|
+ this.entries[toRemovePos] = new FluidDirectionEntry(data, flag);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/core/BlockPosition.java b/src/main/java/net/minecraft/core/BlockPosition.java
|
|
index 8edc279e7a3fdfb7e10718f1deee34b7e3fb2f28..3c51ee00aa53e561c02bb779c7115d8475d70ed7 100644
|
|
--- a/src/main/java/net/minecraft/core/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/core/BlockPosition.java
|
|
@@ -438,12 +438,26 @@ public class BlockPosition extends BaseBlockPosition {
|
|
public BlockPosition b(int i, int j, int k) {
|
|
return super.b(i, j, k).immutableCopy();
|
|
}
|
|
+ // Airplane start - version of b that doesn't copy
|
|
+ public BlockPosition addValues(int x, int y, int z) {
|
|
+ ((BaseBlockPosition)this).a += x;
|
|
+ ((BaseBlockPosition)this).b += y;
|
|
+ ((BaseBlockPosition)this).e += z;
|
|
+ return this;
|
|
+ }
|
|
+ // Airplane end
|
|
|
|
@Override
|
|
public BlockPosition shift(EnumDirection enumdirection, int i) {
|
|
return super.shift(enumdirection, i).immutableCopy();
|
|
}
|
|
|
|
+ // Airplane start - mutable shift method
|
|
+ public MutableBlockPosition mutableShift(EnumDirection enumdirection, int i) {
|
|
+ return this.setValues(this.getX() + enumdirection.getAdjacentX() * i, this.getY() + enumdirection.getAdjacentY() * i, this.getZ() + enumdirection.getAdjacentZ() * i);
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
@Override
|
|
public BlockPosition a(EnumDirection.EnumAxis enumdirection_enumaxis, int i) {
|
|
return super.a(enumdirection_enumaxis, i).immutableCopy();
|
|
diff --git a/src/main/java/net/minecraft/core/EnumDirection.java b/src/main/java/net/minecraft/core/EnumDirection.java
|
|
index 7918d830a4aef09c9f517284e83a9376299116ad..0a40df2151bd388b6633a6f50b14f1f41ed4ce62 100644
|
|
--- a/src/main/java/net/minecraft/core/EnumDirection.java
|
|
+++ b/src/main/java/net/minecraft/core/EnumDirection.java
|
|
@@ -30,7 +30,7 @@ public enum EnumDirection implements INamable {
|
|
private final EnumDirection.EnumAxis k;
|
|
private final EnumDirection.EnumAxisDirection l;
|
|
private final BaseBlockPosition m;
|
|
- private static final EnumDirection[] n = values();
|
|
+ private static final EnumDirection[] n = values(); public static EnumDirection[] getValues() { return n; } // Airplane - getter
|
|
private static final Map<String, EnumDirection> o = (Map) Arrays.stream(EnumDirection.n).collect(Collectors.toMap(EnumDirection::m, (enumdirection) -> {
|
|
return enumdirection;
|
|
}));
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 2767a9369ddc922f1d9c7cb6c7acc8270545535a..2bb00a42492b08036e984d3e1d9a564d4b4226c2 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1646,7 +1646,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
}
|
|
|
|
public String getServerModName() {
|
|
- return "Tuinity"; // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
|
+ return "Airplane"; // Airplane // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
|
}
|
|
|
|
public CrashReport b(CrashReport crashreport) {
|
|
@@ -2196,7 +2196,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
}
|
|
}
|
|
|
|
+ // Airplane start
|
|
+ private final GameProfilerFiller disabledProfiler = net.minecraft.util.profiling.GameProfilerDisabled.a;
|
|
public GameProfilerFiller getMethodProfiler() {
|
|
+ if (gg.airplane.AirplaneConfig.disableMethodProfiler) return disabledProfiler;
|
|
+ // Airplane end
|
|
return this.methodProfiler;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index fa7a78549a9bb92b93c305dc16f43a9ace7f6f43..858bd62d2a17c15ee573c5cd607a876d3a99c2b1 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -216,6 +216,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
|
// Paper end
|
|
com.tuinity.tuinity.config.TuinityConfig.init((java.io.File) options.valueOf("tuinity-settings")); // Tuinity - Server Config
|
|
+ gg.airplane.AirplaneConfig.load(); // Airplane - config
|
|
+ gg.airplane.commands.AirplaneCommands.init(); // Airplane - command
|
|
|
|
this.setPVP(dedicatedserverproperties.pvp);
|
|
this.setAllowFlight(dedicatedserverproperties.allowFlight);
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMapDistance.java b/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
index a5fc023312c99e591fc269999c28a766a46f8849..fb4d006f86229fd093f1a9ea8cab2add0a4cacfa 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMapDistance.java
|
|
@@ -215,7 +215,7 @@ public abstract class ChunkMapDistance {
|
|
public boolean a(PlayerChunkMap playerchunkmap) {
|
|
com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot tick ChunkMapDistance off of the main-thread");// Tuinity
|
|
//this.f.a(); // Paper - no longer used
|
|
- AsyncCatcher.catchOp("DistanceManagerTick"); // Paper
|
|
+ //AsyncCatcher.catchOp("DistanceManagerTick"); // Paper // Airplane - leave up to softEnsures
|
|
//this.g.a(); // Tuinity - no longer used
|
|
boolean flag = this.ticketLevelPropagator.propagateUpdates(); // Tuinity - replace ticket level propagator
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
index fe040615ff03478a20cdf8376f89a6b7d100ba61..207a9c3928aad7c6e89a120b54d87e003ebd232c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
@@ -1000,6 +1000,7 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
}
|
|
// Paper end - optimize isOutisdeRange
|
|
this.world.getMethodProfiler().enter("pollingChunks");
|
|
+ this.world.resetIceAndSnowTick(); // Airplane - reset ice & snow tick random
|
|
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
|
|
boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunk.java b/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
index 86f156587a0939b28c5cf6f64907255c1c4f8b35..06157bb07cce3ba24087ceaca7138b5609b37b5b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunk.java
|
|
@@ -58,6 +58,7 @@ public class PlayerChunk {
|
|
private int ticketLevel; public final void setTicketLevel(final int level) { this.ticketLevel = level; } // Tuinity - OBFHELPER
|
|
volatile int n; public final int getCurrentPriority() { return n; } // Paper - OBFHELPER - make volatile since this is concurrently accessed
|
|
public final ChunkCoordIntPair location; // Paper - private -> public
|
|
+ private final long coordinateKey; // Airplane - cache key for location
|
|
private boolean p;
|
|
private final ShortSet[] dirtyBlocks;
|
|
private int r;
|
|
@@ -80,7 +81,7 @@ public class PlayerChunk {
|
|
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> playersInChunkTickRange;
|
|
|
|
void updateRanges() {
|
|
- long key = net.minecraft.server.MCUtil.getCoordinateKey(this.location);
|
|
+ long key = this.coordinateKey; //net.minecraft.server.MCUtil.getCoordinateKey(this.location); // Airplane - use cached key
|
|
this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key);
|
|
this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
|
|
// Tuinity start - optimise checkDespawn
|
|
@@ -232,7 +233,7 @@ public class PlayerChunk {
|
|
this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
|
this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
|
this.dirtyBlocks = new ShortSet[16];
|
|
- this.location = chunkcoordintpair;
|
|
+ this.location = chunkcoordintpair; this.coordinateKey = net.minecraft.server.MCUtil.getCoordinateKey(this.location); // Airplane
|
|
this.lightEngine = lightengine;
|
|
this.u = playerchunk_c;
|
|
this.players = playerchunk_d;
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
index b28995ecfd7f45e6b6197be96c418aa0d05d3383..914c7a1b18151f29183cfe9474313ce18e7c4ae2 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
@@ -705,7 +705,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
return d2 * d2 + d3 * d3;
|
|
}
|
|
|
|
- private static int b(ChunkCoordIntPair chunkcoordintpair, EntityPlayer entityplayer, boolean flag) {
|
|
+ // Airplane start - create copy that accepts x/z instead of allocating pair
|
|
+ private static int b(ChunkCoordIntPair chunkcoordintpair, EntityPlayer entityplayer, boolean flag) { return someDistanceCalculation(chunkcoordintpair.x, chunkcoordintpair.z, entityplayer, flag); }
|
|
+ private static int someDistanceCalculation(int x, int z, EntityPlayer entityplayer, boolean flag) {
|
|
int i;
|
|
int j;
|
|
|
|
@@ -719,12 +721,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
j = MathHelper.floor(entityplayer.locZ() / 16.0D);
|
|
}
|
|
|
|
- return a(chunkcoordintpair, i, j);
|
|
+ return someOtherDistanceCalculation(x, z, i, j);
|
|
+ // Airplane end
|
|
}
|
|
|
|
- private static int a(ChunkCoordIntPair chunkcoordintpair, int i, int j) {
|
|
- int k = chunkcoordintpair.x - i;
|
|
- int l = chunkcoordintpair.z - j;
|
|
+ // Airplane start - create copy that accepts x/z instead of allocating pair
|
|
+ private static int a(ChunkCoordIntPair chunkcoordintpair, int i, int j) { return someOtherDistanceCalculation(chunkcoordintpair.x, chunkcoordintpair.z, i, j); }
|
|
+ private static int someOtherDistanceCalculation(int x, int z, int i, int j) {
|
|
+ int k = x - i;
|
|
+ int l = z - j;
|
|
+ // Airplane end
|
|
|
|
return Math.max(Math.abs(k), Math.abs(l));
|
|
}
|
|
@@ -2541,11 +2547,17 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
|
boolean flag1 = this.tracker.attachedToPlayer;
|
|
|
|
if (!flag1) {
|
|
+ // Airplane start - use int/longs instead of ChunkCoordIntPair
|
|
+ /*
|
|
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(this.tracker.chunkX, this.tracker.chunkZ);
|
|
- PlayerChunk playerchunk = PlayerChunkMap.this.getVisibleChunk(chunkcoordintpair.pair());
|
|
+ */
|
|
+ int x = this.tracker.chunkX, z = this.tracker.chunkZ;
|
|
+ long chunkcoordintpair = ChunkCoordIntPair.pair(x, z);
|
|
+ PlayerChunk playerchunk = PlayerChunkMap.this.getVisibleChunk(chunkcoordintpair);
|
|
|
|
if (playerchunk != null && playerchunk.getSendingChunk() != null && PlayerChunkMap.this.playerChunkManager.isChunkSent(entityplayer, MathHelper.floor(this.tracker.locX()) >> 4, MathHelper.floor(this.tracker.locZ()) >> 4)) { // Paper - no-tick view distance // Tuinity - don't broadcast in chunks the player hasn't received
|
|
- flag1 = PlayerChunkMap.b(chunkcoordintpair, entityplayer, false) <= PlayerChunkMap.this.viewDistance;
|
|
+ flag1 = PlayerChunkMap.someDistanceCalculation(x, z, entityplayer, false) <= PlayerChunkMap.this.viewDistance;
|
|
+ // Airplane end
|
|
}
|
|
}
|
|
|
|
@@ -2575,8 +2587,10 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
|
}
|
|
|
|
private int b() {
|
|
+ // Airplane start
|
|
+ int i = this.trackingDistance; // move out of if statement
|
|
+ if (!this.tracker.passengers.isEmpty()) {
|
|
Collection<Entity> collection = this.tracker.getAllPassengers();
|
|
- int i = this.trackingDistance;
|
|
Iterator iterator = collection.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
@@ -2588,6 +2602,8 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
|
i = j;
|
|
}
|
|
}
|
|
+ }
|
|
+ // Airplane end
|
|
|
|
return this.a(i);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index 58e61aa19d71011c40c69a691f5644b3e823ad68..51bb2502e4efb052f55de6eabce07f59e936c9d9 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -1107,7 +1107,28 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
|
|
gameprofilerfiller.enter("tick");
|
|
if (!entity.dead && !(entity instanceof EntityComplexPart)) {
|
|
+ // Airplane start - inline this.a to prevent creation of lambda
|
|
+ /*
|
|
this.a(this::entityJoinedWorld, entity);
|
|
+ */
|
|
+ boolean doMidTick = false; // usually there's a returns in the catch, so treat it like that
|
|
+ try {
|
|
+ this.entityJoinedWorld(entity);
|
|
+ doMidTick = true;
|
|
+ } catch (Throwable throwable) {
|
|
+ if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
|
+ // Paper start - Prevent tile entity and entity crashes
|
|
+ String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX() + "," + entity.locY() + "," + entity.locZ();
|
|
+ System.err.println(msg);
|
|
+ throwable.printStackTrace();
|
|
+ getServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable)));
|
|
+ entity.dead = true;
|
|
+ // Paper end
|
|
+ }
|
|
+ if (doMidTick) {
|
|
+ MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick
|
|
+ }
|
|
+ // Airplane end
|
|
}
|
|
|
|
gameprofilerfiller.exit();
|
|
@@ -1202,6 +1223,8 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
private final BiomeBase[] biomeBaseCache = new BiomeBase[1];
|
|
// Tuinity end - optimise chunk ice snow ticking
|
|
|
|
+ private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Airplane
|
|
+
|
|
public void a(Chunk chunk, int i) { final int randomTickSpeed = i; // Paper
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
|
|
boolean flag = this.isRaining();
|
|
@@ -1212,7 +1235,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
gameprofilerfiller.enter("thunder");
|
|
final BlockPosition.MutableBlockPosition blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change
|
|
|
|
- if (!this.paperConfig.disableThunder && flag && this.W() && this.random.nextInt(100000) == 0) { // Paper - Disable thunder
|
|
+ if (!this.paperConfig.disableThunder && flag && chunk.shouldDoLightning(this.random) && this.W()) { // Paper - Disable thunder // Airplane - check this.W last // Airplane - replace random with shouldDoLighting
|
|
blockposition.setValues(this.a(this.a(j, 0, k, 15))); // Paper
|
|
if (this.isRainingAt(blockposition)) {
|
|
DifficultyDamageScaler difficultydamagescaler = this.getDamageScaler(blockposition);
|
|
@@ -1236,7 +1259,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
|
|
gameprofilerfiller.exitEnter("iceandsnow");
|
|
- if (!this.paperConfig.disableIceAndSnow && this.randomTickRandom.nextInt(16) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking
|
|
+ if (!this.paperConfig.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking // Airplane - optimize further random ticking
|
|
// Paper start - optimise chunk ticking
|
|
// Tuinity start - optimise chunk ice snow ticking
|
|
BiomeBase[] biomeCache = this.biomeBaseCache;
|
|
@@ -1449,9 +1472,14 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
++entity.ticksLived;
|
|
GameProfilerFiller gameprofilerfiller = this.getMethodProfiler();
|
|
|
|
+ // Airplane start - create debug lambda once, todo do we even WANT the method profiler?
|
|
+ /*
|
|
gameprofilerfiller.a(() -> {
|
|
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType()).toString();
|
|
});
|
|
+ */
|
|
+ gameprofilerfiller.a(entity.getEntityType().getEntityName);
|
|
+ // Airplane end
|
|
gameprofilerfiller.c("tickNonPassenger");
|
|
if (isActive) { // Paper - EAR 2
|
|
TimingHistory.activatedEntityTicks++; // Paper
|
|
diff --git a/src/main/java/net/minecraft/util/MathHelper.java b/src/main/java/net/minecraft/util/MathHelper.java
|
|
index cc566784c7dd21cc2c44e0f351347f657e57ddcf..e9e7fcf2b63febe2a7d055826fabb86bc13a5cf3 100644
|
|
--- a/src/main/java/net/minecraft/util/MathHelper.java
|
|
+++ b/src/main/java/net/minecraft/util/MathHelper.java
|
|
@@ -240,6 +240,7 @@ public class MathHelper {
|
|
return f - (float) d(f);
|
|
}
|
|
|
|
+ public static double getDecimals(double num) { return h(num); } // Airplane
|
|
public static double h(double d0) {
|
|
return d0 - (double) d(d0);
|
|
}
|
|
@@ -418,6 +419,7 @@ public class MathHelper {
|
|
return f1 + f * (f2 - f1);
|
|
}
|
|
|
|
+ public static double linearInterpolation(double value1, double value2, double amount) { return d(value1, value2, amount); } // Airplane - OBFHELPER
|
|
public static double d(double d0, double d1, double d2) {
|
|
return d1 + d0 * (d2 - d1);
|
|
}
|
|
@@ -434,6 +436,7 @@ public class MathHelper {
|
|
return d0 * d0 * d0 * (d0 * (d0 * 6.0D - 15.0D) + 10.0D);
|
|
}
|
|
|
|
+ public static int sign(double num) { return k(num); } // Airplane - OBFHELPER
|
|
public static int k(double d0) {
|
|
return d0 == 0.0D ? 0 : (d0 > 0.0D ? 1 : -1);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index feab0ae1930b5271fe0d06a40c180317dcbc9d1d..99c93d48726b4b92a341ba98721173df8b4ff30a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -289,6 +289,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
public void inactiveTick() { }
|
|
// Spigot end
|
|
public boolean shouldBeRemoved; // Paper
|
|
+ // Airplane start
|
|
+ public int activatedPriority = gg.airplane.AirplaneConfig.maximumActivationPrio; // golf score
|
|
+ // Airplane end
|
|
|
|
public float getBukkitYaw() {
|
|
return this.yaw;
|
|
@@ -316,10 +319,39 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
this.isLegacyTrackingEntity = isLegacyTrackingEntity;
|
|
}
|
|
|
|
+ // Airplane start - behavior of getAllPassengers + getting bigger range
|
|
+ private org.spigotmc.TrackingRange.TrackingRangeType getBiggestRangeOfPassengers(net.minecraft.server.level.PlayerChunkMap chunkMap, int[] range, Entity entity) {
|
|
+ org.spigotmc.TrackingRange.TrackingRangeType type = null;
|
|
+
|
|
+ for (int i = 0; i < entity.passengers.size(); i++) {
|
|
+ Entity passenger = entity.passengers.get(i);
|
|
+ org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType;
|
|
+ int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal());
|
|
+ if (passengerRange > range[0]) {
|
|
+ type = passengerType;
|
|
+ range[0] = passengerRange;
|
|
+ }
|
|
+
|
|
+ org.spigotmc.TrackingRange.TrackingRangeType childType = this.getBiggestRangeOfPassengers(chunkMap, range, passenger);
|
|
+ if (childType != null) {
|
|
+ type = childType;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return type;
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> getPlayersInTrackRange() {
|
|
+ // Airplane start - replicate behavior of getAllPassengers to skip creating hashset
|
|
+ /*
|
|
Collection<Entity> passengers = this.getAllPassengers();
|
|
+ */
|
|
net.minecraft.server.level.PlayerChunkMap chunkMap = ((WorldServer)this.world).getChunkProvider().playerChunkMap;
|
|
org.spigotmc.TrackingRange.TrackingRangeType type = this.trackingRangeType;
|
|
+ type = this.getBiggestRangeOfPassengers(chunkMap, new int[]{chunkMap.getEntityTrackerRange(type.ordinal())}, this);
|
|
+ if (type == null) type = this.trackingRangeType;
|
|
+ /*
|
|
int range = chunkMap.getEntityTrackerRange(type.ordinal());
|
|
|
|
for (Entity passenger : passengers) {
|
|
@@ -330,8 +362,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
range = passengerRange;
|
|
}
|
|
}
|
|
+ */
|
|
+ // Airplane end
|
|
|
|
- return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this));
|
|
+ return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this.chunkX, this.chunkZ)); // Airplane - don't convert doubles to ints here
|
|
}
|
|
// Paper end - optimise entity tracking
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityInsentient.java b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
index aae13c2e6c2a30b69c33417932c6a4d0aefeb7f5..dc78bafeddf6b584181c818b90efa7ff531377a3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
@@ -201,10 +201,10 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
@Override
|
|
public void inactiveTick() {
|
|
super.inactiveTick();
|
|
- if (this.goalSelector.inactiveTick()) {
|
|
+ if (this.goalSelector.inactiveTick(this.activatedPriority)) { // Airplane - pass activated priroity
|
|
this.goalSelector.doTick();
|
|
}
|
|
- if (this.targetSelector.inactiveTick()) {
|
|
+ if (this.targetSelector.inactiveTick(this.activatedPriority)) { // Airplane - pass activated priority
|
|
this.targetSelector.doTick();
|
|
}
|
|
}
|
|
@@ -774,8 +774,15 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
return false;
|
|
}
|
|
|
|
+ // Airplane start - just reduce frequency of checking for despawn
|
|
+ private byte despawnCheck = 0;
|
|
@Override
|
|
public void checkDespawn() {
|
|
+ if (++despawnCheck < gg.airplane.AirplaneConfig.entityDespawnCheckFrequency) {
|
|
+ return;
|
|
+ }
|
|
+ this.despawnCheck = 0;
|
|
+ // Airplane end
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.L()) {
|
|
this.die();
|
|
} else if (!this.isPersistent() && !this.isSpecialPersistence()) {
|
|
@@ -829,9 +836,11 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
this.bo.a();
|
|
this.world.getMethodProfiler().exit();
|
|
this.world.getMethodProfiler().enter("targetSelector");
|
|
+ if (this.targetSelector.inactiveTick(this.activatedPriority)) // Airplane - use this to alternate ticking
|
|
this.targetSelector.doTick();
|
|
this.world.getMethodProfiler().exit();
|
|
this.world.getMethodProfiler().enter("goalSelector");
|
|
+ if (this.goalSelector.inactiveTick(this.activatedPriority)) // Airplane - use this to alternate ticking
|
|
this.goalSelector.doTick();
|
|
this.world.getMethodProfiler().exit();
|
|
this.world.getMethodProfiler().enter("navigation");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
index 96cc46a26eef701b0579f3407e67af9176e1743b..003e1f6dc8efbabcb2e0f7a6b379196f02203903 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -111,6 +111,7 @@ import net.minecraft.world.phys.AxisAlignedBB;
|
|
import net.minecraft.world.phys.MovingObjectPosition;
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
+import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
|
import net.minecraft.world.scores.ScoreboardTeam;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
@@ -909,11 +910,13 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
if (entity != null) {
|
|
- ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
|
- Item item = itemstack.getItem();
|
|
+ // Airplane start - don't get equipment if not needed
|
|
+ //ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
|
+ //Item item = itemstack.getItem();
|
|
EntityTypes<?> entitytypes = entity.getEntityType();
|
|
|
|
- if (entitytypes == EntityTypes.SKELETON && item == Items.SKELETON_SKULL || entitytypes == EntityTypes.ZOMBIE && item == Items.ZOMBIE_HEAD || entitytypes == EntityTypes.CREEPER && item == Items.CREEPER_HEAD) {
|
|
+ if (entitytypes == EntityTypes.SKELETON && this.getEquipment(EnumItemSlot.HEAD).getItem() == Items.SKELETON_SKULL || entitytypes == EntityTypes.ZOMBIE && this.getEquipment(EnumItemSlot.HEAD).getItem() == Items.ZOMBIE_HEAD || entitytypes == EntityTypes.CREEPER && this.getEquipment(EnumItemSlot.HEAD).getItem() == Items.CREEPER_HEAD) {
|
|
+ // Airplane end
|
|
d0 *= 0.5D;
|
|
}
|
|
}
|
|
@@ -1742,6 +1745,19 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
}
|
|
|
|
+ // Airplane start
|
|
+ private boolean cachedIsClimbing = false;
|
|
+ private BlockPosition lastClimbingPosition = null;
|
|
+
|
|
+ public boolean isClimbingCached() {
|
|
+ if (!this.getChunkCoordinates().equals(this.lastClimbingPosition)) {
|
|
+ this.cachedIsClimbing = this.isClimbing();
|
|
+ this.lastClimbingPosition = this.getChunkCoordinates();
|
|
+ }
|
|
+ return this.cachedIsClimbing;
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
public IBlockData ds() {
|
|
return this.world.getType(this.getChunkCoordinates());
|
|
}
|
|
@@ -3101,7 +3117,7 @@ public abstract class EntityLiving extends Entity {
|
|
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
|
|
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
|
|
|
|
- return this.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.COLLIDER, RayTrace.FluidCollisionOption.NONE, this)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
|
|
+ return this.world.rayTraceDirect(vec3d, vec3d1, VoxelShapeCollision.a(this)) == MovingObjectPosition.EnumMovingObjectType.MISS; // Airplane - use direct method
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityTypes.java b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
index 80c229c1852199fda85c03453d64cae33e413e89..7f70dda656ff9d802200f18139d2695e58c551c7 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
@@ -270,6 +270,8 @@ public class EntityTypes<T extends Entity> {
|
|
private MinecraftKey bq;
|
|
private final EntitySize br;
|
|
|
|
+ public java.util.function.Supplier<String> getEntityName = () -> IRegistry.ENTITY_TYPE.getKey(this).toString(); // Airplane - create lambda ones
|
|
+
|
|
private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
|
|
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
|
|
index 72f1031e95b375823790f8cac4c102ba1205c9e8..e4821c1a7ceac582b019102230dbe5221add9050 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
|
|
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.ai.behavior;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import net.minecraft.core.GlobalPos;
|
|
import net.minecraft.server.level.WorldServer;
|
|
+import net.minecraft.world.entity.EntityLiving;
|
|
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
|
import net.minecraft.world.entity.ai.memory.MemoryStatus;
|
|
import net.minecraft.world.entity.ai.village.poi.VillagePlaceType;
|
|
@@ -21,11 +22,31 @@ public class BehaviorBetterJob extends Behavior<EntityVillager> {
|
|
protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
|
|
GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE).get();
|
|
|
|
+ // Airplane start - remove stream
|
|
+ /*
|
|
worldserver.y().c(globalpos.getBlockPosition()).ifPresent((villageplacetype) -> {
|
|
BehaviorUtil.a(entityvillager, (entityvillager1) -> {
|
|
return this.a(globalpos, villageplacetype, entityvillager1);
|
|
}).reduce(entityvillager, BehaviorBetterJob::a);
|
|
});
|
|
+ */
|
|
+ java.util.Optional<VillagePlaceType> optVillagePlaceType = worldserver.y().c(globalpos.getBlockPosition());
|
|
+ if (optVillagePlaceType.isPresent()) {
|
|
+ VillagePlaceType villageplacetype = optVillagePlaceType.get();
|
|
+ java.util.Optional<java.util.List<EntityLiving>> optList = entityvillager.getBehaviorController().getMemory(MemoryModuleType.MOBS);
|
|
+ if (optList.isPresent()) {
|
|
+ EntityVillager previous = entityvillager;
|
|
+ for (EntityLiving entityliving : optList.get()) {
|
|
+ if (entityliving instanceof EntityVillager && entityliving != entityvillager && entityliving.isAlive()) {
|
|
+ EntityVillager entityvillager1 = (EntityVillager) entityliving;
|
|
+ if (this.a(globalpos, villageplacetype, entityvillager1)) {
|
|
+ previous = a(previous, entityvillager1);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Airplane end
|
|
}
|
|
|
|
private static EntityVillager a(EntityVillager entityvillager, EntityVillager entityvillager1) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFindPosition.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFindPosition.java
|
|
index bc8786e2aaeab4dbae4e9c7666ad816bc5bfac3f..09133c5822bc1386bc3d8a5f3c94196420bbfaea 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFindPosition.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFindPosition.java
|
|
@@ -67,6 +67,7 @@ public class BehaviorFindPosition extends Behavior<EntityCreature> {
|
|
|
|
protected void a(WorldServer worldserver, EntityCreature entitycreature, long i) {
|
|
this.f = i + 20L + (long) worldserver.getRandom().nextInt(20);
|
|
+ if (entitycreature.getNavigation().isStuck()) this.f += 200L; // Airplane - wait an additional 10s to check again if they're stuck
|
|
VillagePlace villageplace = worldserver.y();
|
|
|
|
this.g.long2ObjectEntrySet().removeIf((entry) -> {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalSelector.java
|
|
index 637928664f8c7b1c694a234e507c20724294e450..02e8288473138dcea008d6157318758e8d7ee3be 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalSelector.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalSelector.java
|
|
@@ -44,9 +44,14 @@ public class PathfinderGoalSelector {
|
|
}
|
|
|
|
// Paper start
|
|
- public boolean inactiveTick() {
|
|
- incRate();
|
|
- return getCurRate() % getTickRate() == 0;
|
|
+ public boolean inactiveTick(int tickRate) { // Airplane - take tick rate
|
|
+ tickRate = Math.min(tickRate, getTickRate()); // Airplane
|
|
+ if (this.curRate++ % tickRate != 0) { // Airplane - use tick rate / increment curRate every tick
|
|
+ //incRate();
|
|
+ return false;
|
|
+ } else {
|
|
+ return true;
|
|
+ }
|
|
}
|
|
public boolean hasTasks() {
|
|
for (PathfinderGoalWrapped task : getTasks()) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
|
index 148bdbc2cffb002d8b6dd05e70854ab503804949..48e6a4c588ef39a4bde067d79b96a656c68750ce 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
|
@@ -433,6 +433,7 @@ public abstract class NavigationAbstract {
|
|
}
|
|
}
|
|
|
|
+ public boolean isStuck() { return this.t(); } // Airplane - OBFHELPER
|
|
public boolean t() {
|
|
return this.t;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java b/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java
|
|
index 88972dd8252bd2d2d8e384d616484ff682949fa8..5e8d3b84cbad299e09e8f25bfc712d11e1d1068e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java
|
|
@@ -84,9 +84,17 @@ public class PathfinderTargetCondition {
|
|
}
|
|
|
|
if (this.b > 0.0D) {
|
|
+ // Airplane start - try to return early
|
|
+ double range = (useFollowRange ? getFollowRange(entityliving) : this.b);
|
|
+ double d2 = entityliving.h(entityliving1.locX(), entityliving1.locY(), entityliving1.locZ()); // move up here to use early
|
|
+
|
|
+ if (d2 > range * range) { // if they're further than the absolute furthest allowed, they don't match
|
|
+ return false;
|
|
+ }
|
|
+
|
|
double d0 = this.g ? entityliving1.A(entityliving) : 1.0D;
|
|
- double d1 = Math.max((useFollowRange ? getFollowRange(entityliving) : this.b) * d0, 2.0D); // Paper
|
|
- double d2 = entityliving.h(entityliving1.locX(), entityliving1.locY(), entityliving1.locZ());
|
|
+ double d1 = Math.max(range * d0, 2.0D); // Paper // Airplane - reuse range calculated above
|
|
+ // Airplane end
|
|
|
|
if (d2 > d1 * d1) {
|
|
return false;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
index 61ebb278cf4ef57ae7a86c6c6ef1fa14559f21e2..341b95f73a839a548b202e7bf97fd18760c71fd8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.network.syncher.DataWatcher;
|
|
import net.minecraft.network.syncher.DataWatcherObject;
|
|
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.sounds.SoundEffect;
|
|
import net.minecraft.sounds.SoundEffects;
|
|
import net.minecraft.util.MathHelper;
|
|
@@ -247,13 +248,22 @@ public class EntityBat extends EntityAmbient {
|
|
}
|
|
}
|
|
|
|
+ // Airplane start - only check for spooky season once an hour
|
|
+ private static boolean isSpookySeason = false;
|
|
+ private static final int ONE_HOUR = 20 * 60 * 60;
|
|
+ private static int lastSpookyCheck = -ONE_HOUR;
|
|
private static boolean eJ() {
|
|
+ if (MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) {
|
|
LocalDate localdate = LocalDate.now();
|
|
int i = localdate.get(ChronoField.DAY_OF_MONTH);
|
|
int j = localdate.get(ChronoField.MONTH_OF_YEAR);
|
|
+ isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3;
|
|
+ lastSpookyCheck = MinecraftServer.currentTick;
|
|
+ }
|
|
|
|
- return j == 10 && i >= 20 || j == 11 && i <= 3;
|
|
+ return isSpookySeason;
|
|
}
|
|
+ // Airplane end
|
|
|
|
@Override
|
|
protected float b(EntityPose entitypose, EntitySize entitysize) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java b/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
|
|
index e993b1849beb60515c51ee4f37617faab63ca223..4d7b5d47ab6bd3b1408811c3b9c157b1eb5c30ae 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
|
|
@@ -57,6 +57,7 @@ import net.minecraft.world.level.World;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.Blocks;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
+import net.minecraft.world.level.chunk.Chunk;
|
|
import net.minecraft.world.level.pathfinder.PathType;
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
@@ -314,11 +315,18 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable {
|
|
private boolean p(double d0, double d1, double d2) {
|
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(d0, d1, d2);
|
|
|
|
- while (blockposition_mutableblockposition.getY() > 0 && !this.world.getType(blockposition_mutableblockposition).getMaterial().isSolid()) {
|
|
+ // Airplane start - single chunk lookup
|
|
+ Chunk chunk = this.world.getChunkIfLoaded(blockposition_mutableblockposition);
|
|
+ if (chunk == null) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ while (blockposition_mutableblockposition.getY() > 0 && !chunk.getType(blockposition_mutableblockposition).getMaterial().isSolid()) { // use chunk lookup
|
|
blockposition_mutableblockposition.c(EnumDirection.DOWN);
|
|
}
|
|
|
|
- IBlockData iblockdata = this.world.getType(blockposition_mutableblockposition);
|
|
+ IBlockData iblockdata = chunk.getType(blockposition_mutableblockposition); // use chunk lookup
|
|
+ // Airplane end
|
|
boolean flag = iblockdata.getMaterial().isSolid();
|
|
boolean flag1 = iblockdata.getFluid().a((Tag) TagsFluid.WATER);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java
|
|
index 375409f4b72edc7990da90460b30486fb2980fb6..9aa4850e021076fde306eea7eec104c31086c57f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java
|
|
@@ -54,7 +54,7 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin {
|
|
public int conversionTicks = 0;
|
|
public boolean cannotBeHunted = false;
|
|
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super EntityHoglin>>> bo = ImmutableList.of(SensorType.c, SensorType.d, SensorType.n, SensorType.m);
|
|
- protected static final ImmutableList<? extends MemoryModuleType<?>> bp = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED});
|
|
+ protected static final ImmutableList<MemoryModuleType<?>> bp = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED}); // Airplane - decompile error
|
|
|
|
public EntityHoglin(EntityTypes<? extends EntityHoglin> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -118,15 +118,20 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin {
|
|
|
|
@Override
|
|
public BehaviorController<EntityHoglin> getBehaviorController() {
|
|
- return super.getBehaviorController();
|
|
+ return (BehaviorController<EntityHoglin>) super.getBehaviorController(); // Airplane - decompile error
|
|
}
|
|
|
|
+ private int behaviorTick; // Airplane
|
|
@Override
|
|
protected void mobTick() {
|
|
+ // Airplane - dynamic tick
|
|
+ if (!gg.airplane.AirplaneConfig.dynamicHoglinBehavior || this.behaviorTick++ % this.activatedPriority == 0) {
|
|
this.world.getMethodProfiler().enter("hoglinBrain");
|
|
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
|
|
+ this.getBehaviorController().a((WorldServer) this.world, (EntityHoglin) this); // Airplane - decompile error
|
|
this.world.getMethodProfiler().exit();
|
|
HoglinAI.a(this);
|
|
+ }
|
|
+ // Airplane end
|
|
if (this.isConverting()) {
|
|
++this.conversionTicks;
|
|
if (this.conversionTicks > 300) {
|
|
@@ -300,7 +305,7 @@ public class EntityHoglin extends EntityAnimal implements IMonster, IOglin {
|
|
|
|
@Override
|
|
protected SoundEffect getSoundAmbient() {
|
|
- return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse((Object) null);
|
|
+ return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse(null); // Airplane - decompile error
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/EntityPiglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
|
|
index f2f65dc0612cc232009ea7ff12f5c1ba4e6b15ea..48acef830eb1d919499e9b79dc6a9af4bdf8a17b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
|
|
@@ -188,7 +188,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow {
|
|
|
|
@Override
|
|
public BehaviorController<EntityPiglin> getBehaviorController() {
|
|
- return super.getBehaviorController();
|
|
+ return (BehaviorController<EntityPiglin>) super.getBehaviorController(); // Airplane - compile error
|
|
}
|
|
|
|
@Override
|
|
@@ -244,12 +244,17 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow {
|
|
return !this.cannotHunt;
|
|
}
|
|
|
|
+ private int behaviorTick; // Airplane
|
|
@Override
|
|
protected void mobTick() {
|
|
+ // Airplane - dynamic tick
|
|
+ if (!gg.airplane.AirplaneConfig.dynamicPiglinBehavior || this.behaviorTick++ % this.activatedPriority == 0) {
|
|
this.world.getMethodProfiler().enter("piglinBrain");
|
|
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
|
|
+ this.getBehaviorController().a((WorldServer) this.world, (EntityPiglin) this); // Airplane - compile error
|
|
this.world.getMethodProfiler().exit();
|
|
PiglinAI.b(this);
|
|
+ }
|
|
+ // Airplane end
|
|
super.mobTick();
|
|
}
|
|
|
|
@@ -386,7 +391,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow {
|
|
|
|
@Override
|
|
protected SoundEffect getSoundAmbient() {
|
|
- return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null);
|
|
+ return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // Airplane - compile error
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
|
index 2d0b83923d58cc7b6918b4e2ff2bece13ca26899..d8028675fc82883d716bcfb44431ca6ac7dfda36 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
|
@@ -231,11 +231,17 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
}
|
|
// Spigot End
|
|
|
|
+ private int behaviorTick = 0;
|
|
+
|
|
@Override
|
|
protected void mobTick() { mobTick(false); }
|
|
protected void mobTick(boolean inactive) {
|
|
this.world.getMethodProfiler().enter("villagerBrain");
|
|
- if (!inactive) this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper
|
|
+ if (!inactive) {
|
|
+ if (!gg.airplane.AirplaneConfig.dynamicVillagerBehavior || behaviorTick++ % this.activatedPriority == 0) {
|
|
+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper
|
|
+ }
|
|
+ }
|
|
this.world.getMethodProfiler().exit();
|
|
if (this.bF) {
|
|
this.bF = false;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
index 5bce47fa8f191bc1d33c04c9865cb0efd492a9a2..5f9e64df007ebc40f7bcb50be495b10e51d5b87a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
@@ -162,7 +162,8 @@ public abstract class EntityHuman extends EntityLiving {
|
|
protected int bG;
|
|
protected final float bH = 0.02F;
|
|
private int g;
|
|
- private GameProfile bJ; public final void setProfile(final GameProfile profile) { this.bJ = profile; } // Paper - OBFHELPER
|
|
+ private IChatBaseComponent displayName; // Airplane - cache displayName
|
|
+ private GameProfile bJ; public final void setProfile(final GameProfile profile) { this.bJ = profile; this.displayName = null; } // Paper - OBFHELPER // Airplane - use to reset displayName
|
|
private ItemStack bL;
|
|
private final ItemCooldown bM;
|
|
@Nullable
|
|
@@ -1840,7 +1841,12 @@ public abstract class EntityHuman extends EntityLiving {
|
|
|
|
@Override
|
|
public IChatBaseComponent getDisplayName() {
|
|
- return new ChatComponentText(this.bJ.getName());
|
|
+ // Airplane start - cache display name
|
|
+ if (this.displayName == null) {
|
|
+ this.displayName = new ChatComponentText(this.getProfile().getName());
|
|
+ }
|
|
+ return this.displayName;
|
|
+ // Airplane end
|
|
}
|
|
|
|
public InventoryEnderChest getEnderChest() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/PlayerInventory.java b/src/main/java/net/minecraft/world/entity/player/PlayerInventory.java
|
|
index 2df3ae0b72ccb5f816d55fed15396ba5a1affb7f..754a3ea18905b79ae5ae4fc2442c94f0611b6d0e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/PlayerInventory.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/PlayerInventory.java
|
|
@@ -630,6 +630,8 @@ public class PlayerInventory implements IInventory, INamableTileEntity {
|
|
}
|
|
|
|
public boolean h(ItemStack itemstack) {
|
|
+ // Airplane start - skip using abstract iterators and stuff, they're generic and slow and allocating them sucks
|
|
+ /*
|
|
Iterator iterator = this.f.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
@@ -644,6 +646,20 @@ public class PlayerInventory implements IInventory, INamableTileEntity {
|
|
}
|
|
}
|
|
}
|
|
+ */
|
|
+ List<NonNullList<ItemStack>> components = this.getComponents();
|
|
+ for (int i = 0; i < components.size(); i++) {
|
|
+ List<ItemStack> list = components.get(i);
|
|
+
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
+ ItemStack itemstack1 = list.get(j);
|
|
+
|
|
+ if (!itemstack1.isEmpty() && itemstack1.doMaterialsMatch(itemstack)) {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Airplane end
|
|
|
|
return false;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
index e55061b6c04b4bde92404a6ef58ba9a52cd99c1d..24d205dd1f31ece82d5cf516b8642eb0172e1a97 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
|
|
@@ -4,6 +4,8 @@ import net.minecraft.core.BlockPosition;
|
|
import net.minecraft.core.particles.Particles;
|
|
import net.minecraft.network.protocol.Packet;
|
|
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntityLiving;
|
|
import net.minecraft.world.entity.EntityTypes;
|
|
@@ -102,6 +104,37 @@ public abstract class EntityProjectile extends IProjectile {
|
|
this.setPosition(d0, d1, d2);
|
|
}
|
|
|
|
+ private static int loadedThisTick = 0;
|
|
+ private static int loadedTick;
|
|
+
|
|
+ private int buffered = 0;
|
|
+
|
|
+ // Airplane start
|
|
+ @Override
|
|
+ public void setPosition(double d0, double d1, double d2) {
|
|
+ if (loadedTick != MinecraftServer.currentTick) {
|
|
+ loadedTick = MinecraftServer.currentTick;
|
|
+ loadedThisTick = 0;
|
|
+ }
|
|
+ int previousX = MathHelper.floor(this.locX()) >> 4, previousZ = MathHelper.floor(this.locZ()) >> 4;
|
|
+ int newX = MathHelper.floor(d0) >> 4, newZ = MathHelper.floor(d2) >> 4;
|
|
+ if (previousX != newX || previousZ != newZ) {
|
|
+ boolean isLoaded = this.world.isChunkLoaded(newX, newZ);
|
|
+ if (!isLoaded) {
|
|
+ if (loadedThisTick > 10) { // Airplane 10 = max chunks to load from projectiles in a tick todo config
|
|
+ if (++buffered > 20) { // Airplane 20 = max chunks a single projectile loads overall todo config
|
|
+ this.die();
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ loadedThisTick++;
|
|
+ }
|
|
+ buffered = 0;
|
|
+ }
|
|
+ super.setPosition(d0, d1, d2);
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
protected float k() {
|
|
return 0.03F;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
index e112d149fc3a7af7f0c9a5280c94c9b03b2aba2d..d2afc367fb393c6206f9cd599d4603294d457608 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
@@ -26,8 +26,16 @@ public class ShapelessRecipes implements RecipeCrafting {
|
|
private final String group;
|
|
private final ItemStack result;
|
|
private final NonNullList<RecipeItemStack> ingredients;
|
|
+ private final boolean isBukkit; // Airplane
|
|
|
|
+ // Airplane start - add isBukkit constructor param
|
|
public ShapelessRecipes(MinecraftKey minecraftkey, String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist) {
|
|
+ this(minecraftkey, s, itemstack, nonnulllist, false);
|
|
+ }
|
|
+
|
|
+ public ShapelessRecipes(MinecraftKey minecraftkey, String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist, boolean isBukkit) {
|
|
+ this.isBukkit = isBukkit;
|
|
+ // Airplane end
|
|
this.key = minecraftkey;
|
|
this.group = s;
|
|
this.result = itemstack;
|
|
@@ -69,6 +77,28 @@ public class ShapelessRecipes implements RecipeCrafting {
|
|
}
|
|
|
|
public boolean a(InventoryCrafting inventorycrafting, World world) {
|
|
+ // Airplane start
|
|
+ if (!this.isBukkit) {
|
|
+ java.util.List<RecipeItemStack> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new RecipeItemStack[0]));
|
|
+
|
|
+ inventory: for (int index = 0; index < inventorycrafting.getSize(); index++) {
|
|
+ ItemStack itemStack = inventorycrafting.getItem(index);
|
|
+
|
|
+ if (!itemStack.isEmpty()) {
|
|
+ for (int i = 0; i < ingredients.size(); i++) {
|
|
+ if (ingredients.get(i).test(itemStack)) {
|
|
+ ingredients.remove(i);
|
|
+ continue inventory;
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return ingredients.isEmpty();
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager();
|
|
int i = 0;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/IBlockAccess.java b/src/main/java/net/minecraft/world/level/IBlockAccess.java
|
|
index e612e1d30f76e217b1aa23488ab025adce048f57..c9198d242b9053fad6fa5b53c1894679002d50a7 100644
|
|
--- a/src/main/java/net/minecraft/world/level/IBlockAccess.java
|
|
+++ b/src/main/java/net/minecraft/world/level/IBlockAccess.java
|
|
@@ -14,9 +14,11 @@ import net.minecraft.world.level.block.state.IBlockData;
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.level.material.Material;
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
+import net.minecraft.world.phys.MovingObjectPosition;
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
+import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
|
|
|
public interface IBlockAccess {
|
|
|
|
@@ -56,6 +58,15 @@ public interface IBlockAccess {
|
|
return BlockPosition.a(axisalignedbb).map(this::getType);
|
|
}
|
|
|
|
+ // Airplane start - broken down variant of below rayTraceBlock, used by World#rayTraceDirect
|
|
+ default MovingObjectPosition.EnumMovingObjectType rayTraceBlockDirect(Vec3D vec3d, Vec3D vec3d1, BlockPosition blockposition, IBlockData iblockdata, VoxelShapeCollision voxelshapecoll) {
|
|
+ VoxelShape voxelshape = RayTrace.BlockCollisionOption.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll);
|
|
+ MovingObjectPositionBlock movingobjectpositionblock = this.rayTrace(vec3d, vec3d1, blockposition, voxelshape, iblockdata);
|
|
+
|
|
+ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType();
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
|
default MovingObjectPositionBlock rayTraceBlock(RayTrace raytrace1, BlockPosition blockposition) {
|
|
// Paper start - Prevent raytrace from loading chunks
|
|
diff --git a/src/main/java/net/minecraft/world/level/SpawnerCreature.java b/src/main/java/net/minecraft/world/level/SpawnerCreature.java
|
|
index d497006f05f79015cd791849888832bb53f4a414..d98526785ff2fa3b72e8ffffcb89a57a2203a5c8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/SpawnerCreature.java
|
|
+++ b/src/main/java/net/minecraft/world/level/SpawnerCreature.java
|
|
@@ -415,7 +415,10 @@ public final class SpawnerCreature {
|
|
}
|
|
|
|
private static List<BiomeSettingsMobs.c> a(WorldServer worldserver, StructureManager structuremanager, ChunkGenerator chunkgenerator, EnumCreatureType enumcreaturetype, BlockPosition blockposition, @Nullable BiomeBase biomebase) {
|
|
- return enumcreaturetype == EnumCreatureType.MONSTER && worldserver.getType(blockposition.down()).getBlock() == Blocks.NETHER_BRICKS && structuremanager.a(blockposition, false, StructureGenerator.FORTRESS).e() ? StructureGenerator.FORTRESS.c() : chunkgenerator.getMobsFor(biomebase != null ? biomebase : worldserver.getBiome(blockposition), structuremanager, enumcreaturetype, blockposition);
|
|
+ // Airplane start - single chunk lookup
|
|
+ Chunk chunk;
|
|
+ return enumcreaturetype == EnumCreatureType.MONSTER && (chunk = worldserver.getChunkIfLoaded(blockposition)) != null && chunk.getType(blockposition.down()).getBlock() == Blocks.NETHER_BRICKS && structuremanager.a(blockposition, false, StructureGenerator.FORTRESS).e() ? StructureGenerator.FORTRESS.c() : chunkgenerator.getMobsFor(biomebase != null ? biomebase : worldserver.getBiome(blockposition), structuremanager, enumcreaturetype, blockposition);
|
|
+ // Airplane end
|
|
}
|
|
|
|
private static BlockPosition getRandomPosition(World world, Chunk chunk) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/StructureManager.java b/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
index 43418273f00f3703c7bd86586847d469af92c18f..d11e79093f9a5121c98b7da840bc79d204895b65 100644
|
|
--- a/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
+++ b/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
@@ -16,6 +16,11 @@ import net.minecraft.world.level.levelgen.feature.StructureGenerator;
|
|
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
|
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
|
|
|
+// Airplane start
|
|
+import it.unimi.dsi.fastutil.longs.LongIterator;
|
|
+import it.unimi.dsi.fastutil.longs.LongSet;
|
|
+// Airplane end
|
|
+
|
|
public class StructureManager {
|
|
|
|
private final GeneratorAccess a; public GeneratorAccess getLevel() { return a; } // Paper - OBFHELPER
|
|
@@ -52,13 +57,15 @@ public class StructureManager {
|
|
public java.util.List<StructureStart<?>> getFeatureStarts(SectionPosition sectionPosition, StructureGenerator<?> structureGenerator, IWorldReader world) {
|
|
// Tuinity end - add world parameter
|
|
java.util.List<StructureStart<?>> list = new ObjectArrayList<>();
|
|
- for (Long curLong: (world == null ? getLevel() : world).getChunkAt(sectionPosition.a(), sectionPosition.c(), ChunkStatus.STRUCTURE_REFERENCES).b(structureGenerator)) { // Tuinity - fix deadlock on world gen - chunk can be unloaded while generating, so we should be using the generator's regionlimitedaccess so we always get the chunk
|
|
- SectionPosition sectionPosition1 = SectionPosition.a(new ChunkCoordIntPair(curLong), 0);
|
|
+ // Airplane start - skip allocating Longs
|
|
+ (world == null ? getLevel() : world).getChunkAt(sectionPosition.a(), sectionPosition.c(), ChunkStatus.STRUCTURE_REFERENCES).b(structureGenerator).forEach((java.util.function.LongConsumer) curLong -> {
|
|
+ SectionPosition sectionPosition1 = SectionPosition.a(ChunkCoordIntPair.getX(curLong), 0, ChunkCoordIntPair.getZ(curLong)); // don't allocate ChunkCoordIntPair
|
|
StructureStart<?> structurestart = a(sectionPosition1, structureGenerator, getLevel().getChunkAt(sectionPosition1.a(), sectionPosition1.c(), ChunkStatus.STRUCTURE_STARTS));
|
|
if (structurestart != null && structurestart.e()) {
|
|
list.add(structurestart);
|
|
}
|
|
- }
|
|
+ });
|
|
+ // Airplane end
|
|
return list;
|
|
}
|
|
// Paper end
|
|
@@ -86,7 +93,18 @@ public class StructureManager {
|
|
}
|
|
public StructureStart<?> getStructureStarts(BlockPosition blockposition, boolean flag, StructureGenerator<?> structuregenerator, IWorldReader world) {
|
|
// Paper start - remove structure streams
|
|
- for (StructureStart<?> structurestart : getFeatureStarts(SectionPosition.a(blockposition), structuregenerator, world)) { // Tuinity end - add world parameter
|
|
+ // Airplane start - inline getFeatureStarts to skip creating the list
|
|
+ SectionPosition sectionPosition = SectionPosition.a(blockposition);
|
|
+
|
|
+ // use iterator here instead of forEach like in getFeatureStarts so we can return early
|
|
+ LongSet longSet = (world == null ? getLevel() : world).getChunkAt(sectionPosition.a(), sectionPosition.c(), ChunkStatus.STRUCTURE_REFERENCES).b(structuregenerator);
|
|
+ LongIterator iterator = longSet.iterator();
|
|
+ while (iterator.hasNext()) {
|
|
+ long curLong = iterator.nextLong();
|
|
+ SectionPosition sectionPosition1 = SectionPosition.a(ChunkCoordIntPair.getX(curLong), 0, ChunkCoordIntPair.getZ(curLong)); // don't allocate ChunkCoordIntPair
|
|
+ StructureStart<?> structurestart = a(sectionPosition1, structuregenerator, getLevel().getChunkAt(sectionPosition1.a(), sectionPosition1.c(), ChunkStatus.STRUCTURE_STARTS));
|
|
+ if (structurestart != null && structurestart.e()) {
|
|
+
|
|
if (structurestart.c().b(blockposition)) {
|
|
if (!flag) {
|
|
return structurestart;
|
|
@@ -97,7 +115,10 @@ public class StructureManager {
|
|
}
|
|
}
|
|
}
|
|
+
|
|
+ }
|
|
}
|
|
+ // Airplane end
|
|
return StructureStart.a;
|
|
// Paper end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
|
index af01f5d635eada7175b9d7fdb47a65530686a539..51e6cd6119465f9fd6385072997971449afb5f42 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -69,6 +69,8 @@ import net.minecraft.world.level.saveddata.maps.WorldMap;
|
|
import net.minecraft.world.level.storage.WorldData;
|
|
import net.minecraft.world.level.storage.WorldDataMutable;
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
+import net.minecraft.world.phys.MovingObjectPosition;
|
|
+import net.minecraft.world.phys.Vec3D;
|
|
import net.minecraft.world.phys.shapes.OperatorBoolean;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
|
@@ -104,7 +106,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
|
|
public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
|
|
protected final List<TileEntity> tileEntityListPending = Lists.newArrayList();
|
|
- protected final java.util.Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet();
|
|
+ protected final java.util.Set<TileEntity> tileEntityListUnload = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); // Airplane - use set with faster contains
|
|
public final Thread serverThread;
|
|
private final boolean debugWorld;
|
|
private int d;
|
|
@@ -378,6 +380,91 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
return null;
|
|
}
|
|
|
|
+ // Airplane start - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace)
|
|
+ public MovingObjectPosition.EnumMovingObjectType rayTraceDirect(Vec3D vec3d, Vec3D vec3d1, VoxelShapeCollision voxelshapecoll) {
|
|
+ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions
|
|
+ if (vec3d.equals(vec3d1)) {
|
|
+ return MovingObjectPosition.EnumMovingObjectType.MISS;
|
|
+ }
|
|
+
|
|
+ double endX = MathHelper.linearInterpolation(-1.0E-7D, vec3d1.x, vec3d.x);
|
|
+ double endY = MathHelper.linearInterpolation(-1.0E-7D, vec3d1.y, vec3d.y);
|
|
+ double endZ = MathHelper.linearInterpolation(-1.0E-7D, vec3d1.z, vec3d.z);
|
|
+
|
|
+ double startX = MathHelper.linearInterpolation(-1.0E-7D, vec3d.x, vec3d1.x);
|
|
+ double startY = MathHelper.linearInterpolation(-1.0E-7D, vec3d.y, vec3d1.y);
|
|
+ double startZ = MathHelper.linearInterpolation(-1.0E-7D, vec3d.z, vec3d1.z);
|
|
+
|
|
+ int currentX = MathHelper.floor(startX);
|
|
+ int currentY = MathHelper.floor(startY);
|
|
+ int currentZ = MathHelper.floor(startZ);
|
|
+
|
|
+ BlockPosition.MutableBlockPosition currentBlock = new BlockPosition.MutableBlockPosition(currentX, currentY, currentZ);
|
|
+
|
|
+ Chunk chunk = this.getChunkIfLoaded(currentBlock);
|
|
+ if (chunk == null) {
|
|
+ return MovingObjectPosition.EnumMovingObjectType.MISS;
|
|
+ }
|
|
+
|
|
+ MovingObjectPosition.EnumMovingObjectType initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getType(currentBlock), voxelshapecoll);
|
|
+
|
|
+ if (initialCheck != null) {
|
|
+ return initialCheck;
|
|
+ }
|
|
+
|
|
+ double diffX = endX - startX;
|
|
+ double diffY = endY - startY;
|
|
+ double diffZ = endZ - startZ;
|
|
+
|
|
+ int xDirection = MathHelper.sign(diffX);
|
|
+ int yDirection = MathHelper.sign(diffY);
|
|
+ int zDirection = MathHelper.sign(diffZ);
|
|
+
|
|
+ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX;
|
|
+ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY;
|
|
+ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ;
|
|
+
|
|
+ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - MathHelper.getDecimals(startX) : MathHelper.getDecimals(startX));
|
|
+ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - MathHelper.getDecimals(startY) : MathHelper.getDecimals(startY));
|
|
+ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - MathHelper.getDecimals(startZ) : MathHelper.getDecimals(startZ));
|
|
+
|
|
+ MovingObjectPosition.EnumMovingObjectType result;
|
|
+
|
|
+ do {
|
|
+ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) {
|
|
+ return MovingObjectPosition.EnumMovingObjectType.MISS;
|
|
+ }
|
|
+
|
|
+ if (normalizedXDirection < normalizedYDirection) {
|
|
+ if (normalizedXDirection < normalizedZDirection) {
|
|
+ currentX += xDirection;
|
|
+ normalizedXDirection += normalizedX;
|
|
+ } else {
|
|
+ currentZ += zDirection;
|
|
+ normalizedZDirection += normalizedZ;
|
|
+ }
|
|
+ } else if (normalizedYDirection < normalizedZDirection) {
|
|
+ currentY += yDirection;
|
|
+ normalizedYDirection += normalizedY;
|
|
+ } else {
|
|
+ currentZ += zDirection;
|
|
+ normalizedZDirection += normalizedZ;
|
|
+ }
|
|
+
|
|
+ currentBlock.setValues(currentX, currentY, currentZ);
|
|
+ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) {
|
|
+ chunk = this.getChunkIfLoaded(currentBlock);
|
|
+ if (chunk == null) {
|
|
+ return MovingObjectPosition.EnumMovingObjectType.MISS;
|
|
+ }
|
|
+ }
|
|
+ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getType(currentBlock), voxelshapecoll);
|
|
+ } while (result == null);
|
|
+
|
|
+ return result;
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
public static boolean isValidLocation(BlockPosition blockposition) {
|
|
return blockposition.isValidLocation(); // Paper - use better/optimized check
|
|
}
|
|
@@ -899,12 +986,17 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
gameprofilerfiller.enter("blockEntities");
|
|
timings.tileEntityTick.startTiming(); // Spigot
|
|
if (!this.tileEntityListUnload.isEmpty()) {
|
|
+ // Airplane start - we just use the identitymap as the basis for the unload set now instead of copying
|
|
+ /*
|
|
// Paper start - Use alternate implementation with faster contains
|
|
java.util.Set<TileEntity> toRemove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
|
|
toRemove.addAll(tileEntityListUnload);
|
|
this.tileEntityListTick.removeAll(toRemove);
|
|
// Paper end
|
|
//this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list
|
|
+ */
|
|
+ this.tileEntityListTick.removeAll(this.tileEntityListUnload);
|
|
+ // Airplane end
|
|
this.tileEntityListUnload.clear();
|
|
}
|
|
|
|
@@ -1016,19 +1108,19 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
|
|
public void a(Consumer<Entity> consumer, Entity entity) {
|
|
try {
|
|
- consumer.accept(entity);
|
|
+ consumer.accept(entity); // Airplane - error on change
|
|
} catch (Throwable throwable) {
|
|
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
|
// Paper start - Prevent tile entity and entity crashes
|
|
String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX() + "," + entity.locY() + "," + entity.locZ();
|
|
System.err.println(msg);
|
|
throwable.printStackTrace();
|
|
- getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable)));
|
|
+ getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); // Airplane - error on change
|
|
entity.dead = true;
|
|
return;
|
|
// Paper end
|
|
}
|
|
- MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick
|
|
+ MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick // Airplane - error on change
|
|
}
|
|
// Paper start - Prevent armor stands from doing entity lookups
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index 596b4597313b87296d39027b13555b5ad1cba9e6..f8a982add50862f1bc977f3039e7e9aeed9138ae 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -392,6 +392,7 @@ public class Block extends BlockBase implements IMaterial {
|
|
return this.d;
|
|
}
|
|
|
|
+ /** currently seems to only return true for MOVING_PISTON and SCAFFOLDING */ public boolean isComplexHitbox() { return this.o(); } // Airplane - OBFHELPER
|
|
public boolean o() {
|
|
return this.aA;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java b/src/main/java/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java
|
|
index 712596420af83e6e1b9d147ae2fd8d8a1f36e1b9..9c29fa3efac7e16df81b8a44934e3286bb37f1f6 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java
|
|
@@ -54,8 +54,14 @@ public abstract class BlockDirtSnowSpreadable extends BlockDirtSnow {
|
|
if (worldserver.getLightLevel(blockposition.up()) >= 9) {
|
|
IBlockData iblockdata1 = this.getBlockData();
|
|
|
|
+ // Airplane start - use mutable position
|
|
+ BlockPosition.MutableBlockPosition blockposition1 = new BlockPosition.MutableBlockPosition();
|
|
for (int i = 0; i < 4; ++i) {
|
|
+ blockposition1.setValues(blockposition).addValues(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
|
+ /*
|
|
BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
|
+ */
|
|
+ // Airplane end
|
|
|
|
if (worldserver.getType(blockposition1).a(Blocks.DIRT) && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) {
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockFire.java b/src/main/java/net/minecraft/world/level/block/BlockFire.java
|
|
index 70c32b7a53a1107cced3491ebac19b0eaf4fec2e..3f3e241f3b24d9df9d57760c5515ff021718065a 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockFire.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockFire.java
|
|
@@ -340,13 +340,15 @@ public class BlockFire extends BlockFireAbstract {
|
|
return 0;
|
|
} else {
|
|
int i = 0;
|
|
- EnumDirection[] aenumdirection = EnumDirection.values();
|
|
+ EnumDirection[] aenumdirection = EnumDirection.getValues(); // Airplane - don't allocate new array here
|
|
int j = aenumdirection.length;
|
|
|
|
+ BlockPosition.MutableBlockPosition copy = new BlockPosition.MutableBlockPosition(); // Airplane - single allocation for this method
|
|
for (int k = 0; k < j; ++k) {
|
|
+ copy.setValues(blockposition); // Airplane - reset values
|
|
EnumDirection enumdirection = aenumdirection[k];
|
|
// Paper start
|
|
- IBlockData iblockdata = iworldreader.getTypeIfLoaded(blockposition.shift(enumdirection));
|
|
+ IBlockData iblockdata = iworldreader.getTypeIfLoaded(copy.mutableShift(enumdirection, 1)); // Airplane - mutable shift
|
|
if (iblockdata == null) {
|
|
continue;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/Chunk.java b/src/main/java/net/minecraft/world/level/chunk/Chunk.java
|
|
index fc07e2014e961da5d97095c4ee6f972e2ece3ec3..8f5809756b4fb358f1207c1d61c5cbe6df3fff00 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/Chunk.java
|
|
@@ -99,6 +99,18 @@ public class Chunk implements IChunkAccess {
|
|
private final ChunkCoordIntPair loc; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key
|
|
private volatile boolean x;
|
|
|
|
+ // Airplane start - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively
|
|
+ private int lightningTick;
|
|
+ // shouldDoLightning compiles down to 29 bytes, which with the default of 35 byte inlining should guarantee an inline
|
|
+ public final boolean shouldDoLightning(java.util.Random random) {
|
|
+ if (this.lightningTick-- <= 0) {
|
|
+ this.lightningTick = random.nextInt(100000) << 1;
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage) {
|
|
this(world, chunkcoordintpair, biomestorage, ChunkConverter.a, TickListEmpty.b(), TickListEmpty.b(), 0L, (ChunkSection[]) null, (Consumer) null);
|
|
}
|
|
@@ -333,6 +345,7 @@ public class Chunk implements IChunkAccess {
|
|
// CraftBukkit start
|
|
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
|
this.entitySlicesManager = new com.tuinity.tuinity.world.ChunkEntitySlices(this.world, this.loc.x, this.loc.z, 0, 15); // TODO update for 1.17 // Tuinity
|
|
+ this.lightningTick = this.world.random.nextInt(100000) << 1; // Airplane - initialize lightning tick
|
|
}
|
|
|
|
public org.bukkit.Chunk bukkitChunk;
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/DataPaletteBlock.java b/src/main/java/net/minecraft/world/level/chunk/DataPaletteBlock.java
|
|
index a6937366cd9c9d708edb5cd1ab3ac096e7b2032e..a579c5bf9e20c74aa3bf8ef6bc00576409805ca6 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/DataPaletteBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/DataPaletteBlock.java
|
|
@@ -235,12 +235,16 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
|
|
this.b();
|
|
}
|
|
|
|
+ // Airplane start - add parameter for reusing aint
|
|
public synchronized void a(NBTTagCompound nbttagcompound, String s, String s1) { // Paper - synchronize
|
|
+ a(nbttagcompound, s, s1, new int[4096]);
|
|
+ }
|
|
+ public synchronized void a(NBTTagCompound nbttagcompound, String s, String s1, int[] aint) { // Paper - synchronize // Airplane end
|
|
this.a();
|
|
DataPaletteHash<T> datapalettehash = new DataPaletteHash<>(this.d, this.i, this.c, this.e, this.f);
|
|
T t0 = this.g;
|
|
int i = datapalettehash.a(this.g);
|
|
- int[] aint = new int[4096];
|
|
+ //int[] aint = new int[4096]; // Airplane - use parameter
|
|
|
|
for (int j = 0; j < 4096; ++j) {
|
|
T t1 = this.a(j);
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
|
|
index ec2b238480413ba9c123d9ddeaa787d9520e1b74..bf96f9e538fc29ca914536e8a7ce727ebe43a8b2 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
|
|
@@ -468,6 +468,7 @@ public class ChunkRegionLoader {
|
|
public static NBTTagCompound saveChunk(WorldServer worldserver, IChunkAccess ichunkaccess) {
|
|
return saveChunk(worldserver, ichunkaccess, null);
|
|
}
|
|
+ private static final ThreadLocal<int[]> paletteArray = ThreadLocal.withInitial(() -> new int[4096]); // Airplane
|
|
public static NBTTagCompound saveChunk(WorldServer worldserver, IChunkAccess ichunkaccess, AsyncSaveData asyncsavedata) {
|
|
// Paper end
|
|
// Tuinity start - rewrite light impl
|
|
@@ -498,6 +499,7 @@ public class ChunkRegionLoader {
|
|
|
|
NBTTagCompound nbttagcompound2;
|
|
|
|
+ int[] aint = paletteArray.get(); // Airplane - use cached
|
|
for (int i = -1; i < 17; ++i) { // Paper - conflict on loop parameter change
|
|
int finalI = i; // CraftBukkit - decompile errors
|
|
ChunkSection chunksection = (ChunkSection) Arrays.stream(achunksection).filter((chunksection1) -> {
|
|
@@ -518,7 +520,7 @@ public class ChunkRegionLoader {
|
|
nbttagcompound2 = new NBTTagCompound();
|
|
nbttagcompound2.setByte("Y", (byte) (i & 255));
|
|
if (chunksection != Chunk.a) {
|
|
- chunksection.getBlocks().a(nbttagcompound2, "Palette", "BlockStates");
|
|
+ chunksection.getBlocks().a(nbttagcompound2, "Palette", "BlockStates", aint); // Airplane
|
|
}
|
|
|
|
if (nibblearray != null && !nibblearray.c()) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/material/FluidTypeFlowing.java b/src/main/java/net/minecraft/world/level/material/FluidTypeFlowing.java
|
|
index 6bb4ec00e40795ced73648fefcd1f5027e0113cd..b14b0134b42aa6d1eb285aa453ec6067cc702878 100644
|
|
--- a/src/main/java/net/minecraft/world/level/material/FluidTypeFlowing.java
|
|
+++ b/src/main/java/net/minecraft/world/level/material/FluidTypeFlowing.java
|
|
@@ -45,6 +45,8 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
|
|
public static final BlockStateBoolean FALLING = BlockProperties.i;
|
|
public static final BlockStateInteger LEVEL = BlockProperties.at;
|
|
+ // Airplane start - use our own threadlocal cache
|
|
+ /*
|
|
private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.a>> e = ThreadLocal.withInitial(() -> {
|
|
Object2ByteLinkedOpenHashMap<Block.a> object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.a>(200) {
|
|
protected void rehash(int i) {}
|
|
@@ -53,6 +55,13 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
object2bytelinkedopenhashmap.defaultReturnValue((byte) 127);
|
|
return object2bytelinkedopenhashmap;
|
|
});
|
|
+ */
|
|
+ private static final ThreadLocal<gg.airplane.structs.FluidDirectionCache<Block.a>> localFluidDirectionCache = ThreadLocal.withInitial(() -> {
|
|
+ // Airplane todo - mess with this number for performance
|
|
+ // with 1024 it seems very infrequent on a small world that it has to remove old entries
|
|
+ return new gg.airplane.structs.FluidDirectionCache<>(1024);
|
|
+ });
|
|
+ // Airplane end
|
|
private final Map<Fluid, VoxelShape> f = Maps.newIdentityHashMap();
|
|
|
|
public FluidTypeFlowing() {}
|
|
@@ -240,6 +249,8 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
}
|
|
|
|
private boolean a(EnumDirection enumdirection, IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata, BlockPosition blockposition1, IBlockData iblockdata1) {
|
|
+ // Airplane start - modify to use our cache
|
|
+ /*
|
|
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
|
|
|
if (!iblockdata.getBlock().o() && !iblockdata1.getBlock().o()) {
|
|
@@ -247,9 +258,16 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
} else {
|
|
object2bytelinkedopenhashmap = null;
|
|
}
|
|
+ */
|
|
+ gg.airplane.structs.FluidDirectionCache<Block.a> cache = null;
|
|
+
|
|
+ if (!iblockdata.getBlock().isComplexHitbox() && !iblockdata1.getBlock().isComplexHitbox()) {
|
|
+ cache = localFluidDirectionCache.get();
|
|
+ }
|
|
|
|
Block.a block_a;
|
|
|
|
+ /*
|
|
if (object2bytelinkedopenhashmap != null) {
|
|
block_a = new Block.a(iblockdata, iblockdata1, enumdirection);
|
|
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
|
@@ -260,11 +278,22 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
} else {
|
|
block_a = null;
|
|
}
|
|
+ */
|
|
+ if (cache != null) {
|
|
+ block_a = new Block.a(iblockdata, iblockdata1, enumdirection);
|
|
+ Boolean flag = cache.getValue(block_a);
|
|
+ if (flag != null) {
|
|
+ return flag;
|
|
+ }
|
|
+ } else {
|
|
+ block_a = null;
|
|
+ }
|
|
|
|
VoxelShape voxelshape = iblockdata.getCollisionShape(iblockaccess, blockposition);
|
|
VoxelShape voxelshape1 = iblockdata1.getCollisionShape(iblockaccess, blockposition1);
|
|
boolean flag = !VoxelShapes.b(voxelshape, voxelshape1, enumdirection);
|
|
|
|
+ /*
|
|
if (object2bytelinkedopenhashmap != null) {
|
|
if (object2bytelinkedopenhashmap.size() == 200) {
|
|
object2bytelinkedopenhashmap.removeLastByte();
|
|
@@ -272,6 +301,11 @@ public abstract class FluidTypeFlowing extends FluidType {
|
|
|
|
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
|
}
|
|
+ */
|
|
+ if (cache != null) {
|
|
+ cache.putValue(block_a, flag);
|
|
+ }
|
|
+ // Airplane end
|
|
|
|
return flag;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTableInfo.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTableInfo.java
|
|
index 95d0c9f22d79194ca83ca6f6a8e6d91180a3c8da..20cc04be75ab202d4c4ee9a07e9876ceff8422ca 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootTableInfo.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTableInfo.java
|
|
@@ -43,8 +43,8 @@ public class LootTableInfo {
|
|
this.world = worldserver;
|
|
this.d = function;
|
|
this.f = function1;
|
|
- this.h = ImmutableMap.copyOf(map);
|
|
- this.i = ImmutableMap.copyOf(map1);
|
|
+ this.h = java.util.Collections.unmodifiableMap(map); // Airplane
|
|
+ this.i = java.util.Collections.unmodifiableMap(map1); // Airplane
|
|
}
|
|
|
|
public boolean hasContextParameter(LootContextParameter<?> lootcontextparameter) {
|
|
@@ -62,7 +62,7 @@ public class LootTableInfo {
|
|
|
|
@Nullable
|
|
public <T> T getContextParameter(LootContextParameter<T> lootcontextparameter) {
|
|
- return this.h.get(lootcontextparameter);
|
|
+ return (T) this.h.get(lootcontextparameter); // Airplane - compile error
|
|
}
|
|
|
|
public boolean a(LootTable loottable) {
|
|
@@ -216,7 +216,7 @@ public class LootTableInfo {
|
|
}
|
|
|
|
public <T> T a(LootContextParameter<T> lootcontextparameter) {
|
|
- T t0 = this.b.get(lootcontextparameter);
|
|
+ T t0 = (T) this.b.get(lootcontextparameter); // Airplane - compile error
|
|
|
|
if (t0 == null) {
|
|
throw new IllegalArgumentException("No parameter " + lootcontextparameter);
|
|
@@ -227,7 +227,7 @@ public class LootTableInfo {
|
|
|
|
@Nullable
|
|
public <T> T b(LootContextParameter<T> lootcontextparameter) {
|
|
- return this.b.get(lootcontextparameter);
|
|
+ return (T) this.b.get(lootcontextparameter); // Airplane - compile error
|
|
}
|
|
|
|
public LootTableInfo build(LootContextParameterSet lootcontextparameterset) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index fd3333fef4112e6469ccd316ba2c82926c04e5db..aec6c036ed42078a6cc3540f1f6e46a551e87a2f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -232,7 +232,7 @@ import javax.annotation.Nullable; // Paper
|
|
import javax.annotation.Nonnull; // Paper
|
|
|
|
public final class CraftServer implements Server {
|
|
- private final String serverName = "Tuinity"; // Paper // Tuinity
|
|
+ private final String serverName = "Airplane"; // Paper // Tuinity // Airplane
|
|
private final String serverVersion;
|
|
private final String bukkitVersion = Versioning.getBukkitVersion();
|
|
private final Logger logger = Logger.getLogger("Minecraft");
|
|
@@ -978,6 +978,11 @@ public final class CraftServer implements Server {
|
|
plugin.getDescription().getName(),
|
|
"This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
|
));
|
|
+ getLogger().log(Level.SEVERE, String.format("%s Stacktrace", worker.getThread().getName()));
|
|
+ StackTraceElement[] stackTrace = worker.getThread().getStackTrace();
|
|
+ for (StackTraceElement element : stackTrace) {
|
|
+ getLogger().log(Level.SEVERE, " " + element.toString());
|
|
+ }
|
|
}
|
|
}
|
|
// Paper end
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
index de9c5ed6b03a290fe77eec719f0079fd7bd9b7f5..8c02f6fdffb59153712a3be778f9c454fd87b73b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
|
data.set(i, toNMS(ingred.get(i), true));
|
|
}
|
|
|
|
- MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data));
|
|
+ MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data, true)); // Airplane
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java b/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java
|
|
index 49dc0c441b9dd7e7745cf15ced67f383ebee1f99..b343d8ee7435312929558efdaf127334d8e2fff6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/MinecraftInternalPlugin.java
|
|
@@ -19,7 +19,8 @@ public class MinecraftInternalPlugin extends PluginBase {
|
|
private boolean enabled = true;
|
|
|
|
private final String pluginName;
|
|
- private PluginDescriptionFile pdf;
|
|
+ private org.bukkit.plugin.PluginLogger logger;
|
|
+ private PluginDescriptionFile pdf; // Airplane
|
|
|
|
public MinecraftInternalPlugin() {
|
|
this.pluginName = "Minecraft";
|
|
@@ -72,7 +73,12 @@ public class MinecraftInternalPlugin extends PluginBase {
|
|
|
|
@Override
|
|
public PluginLogger getLogger() {
|
|
- throw new UnsupportedOperationException("Not supported.");
|
|
+ // Airplane start
|
|
+ if (this.logger == null) {
|
|
+ this.logger = new org.bukkit.plugin.PluginLogger(this); // Airplane
|
|
+ }
|
|
+ return this.logger;
|
|
+ // Airplane end
|
|
}
|
|
|
|
@Override
|
|
@@ -82,7 +88,7 @@ public class MinecraftInternalPlugin extends PluginBase {
|
|
|
|
@Override
|
|
public Server getServer() {
|
|
- throw new UnsupportedOperationException("Not supported.");
|
|
+ return org.bukkit.Bukkit.getServer(); // Airplane - impl
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
index 001b1e5197eaa51bfff9031aa6c69876c9a47960..1788d79ea489e446d3d9f541693d4ba3dfc26015 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
@@ -11,7 +11,7 @@ public final class Versioning {
|
|
public static String getBukkitVersion() {
|
|
String result = "Unknown-Version";
|
|
|
|
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.tuinity/tuinity-api/pom.properties"); // Tuinity
|
|
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/gg.airplane/airplane-api/pom.properties"); // Tuinity // Airplane
|
|
Properties properties = new Properties();
|
|
|
|
if (stream != null) {
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index 5c2eaca0bc63c7880ee928aba6a24761737aa649..94910bf0c53c79588c55b89e4a023273d6c859ef 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -47,6 +47,9 @@ import net.minecraft.world.entity.schedule.Activity;
|
|
import net.minecraft.world.entity.item.EntityFallingBlock;
|
|
import net.minecraft.world.entity.projectile.EntityEnderSignal;
|
|
// Paper end
|
|
+// Airplane start
|
|
+import net.minecraft.world.phys.Vec3D;
|
|
+// Airplane end
|
|
|
|
public class ActivationRange
|
|
{
|
|
@@ -227,7 +230,7 @@ public class ActivationRange
|
|
Chunk chunk = chunkProvider.getChunkAtIfLoadedMainThreadNoCache( i1, j1 ); // Paper
|
|
if ( chunk != null )
|
|
{
|
|
- activateChunkEntities( chunk );
|
|
+ activateChunkEntities( chunk, player.getPositionVector() ); // Airplane
|
|
}
|
|
}
|
|
}
|
|
@@ -240,7 +243,7 @@ public class ActivationRange
|
|
*
|
|
* @param chunk
|
|
*/
|
|
- private static void activateChunkEntities(Chunk chunk)
|
|
+ private static void activateChunkEntities(Chunk chunk, Vec3D playerVec) // Airplane - add player location
|
|
{
|
|
// Paper start
|
|
Entity[] rawData = chunk.entities.getRawData();
|
|
@@ -249,6 +252,15 @@ public class ActivationRange
|
|
//for ( Entity entity : (Collection<Entity>) slice )
|
|
// Paper end
|
|
{
|
|
+ // Airplane start
|
|
+ Vec3D entityVec = entity.getPositionVector();
|
|
+ double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z;
|
|
+ int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ);
|
|
+ entity.activatedPriority = squaredDistance > gg.airplane.AirplaneConfig.startDistanceSquared ?
|
|
+ Math.max(1, Math.min(squaredDistance >> gg.airplane.AirplaneConfig.activationDistanceMod, gg.airplane.AirplaneConfig.maximumActivationPrio)) :
|
|
+ 1;
|
|
+ // Airplane end
|
|
+
|
|
if (MinecraftServer.currentTick > entity.activatedTick) {
|
|
if (entity.defaultActivationState || entity.activationType.boundingBox.c(entity.getBoundingBox())) { // Paper
|
|
entity.activatedTick = MinecraftServer.currentTick;
|
|
@@ -297,7 +309,7 @@ public class ActivationRange
|
|
if ( entity instanceof EntityLiving )
|
|
{
|
|
EntityLiving living = (EntityLiving) entity;
|
|
- if ( living.isClimbing() || living.jumping || living.hurtTicks > 0 || living.effects.size() > 0 ) // Paper
|
|
+ if ( living.isClimbingCached() || living.jumping || living.hurtTicks > 0 || living.effects.size() > 0 ) // Paper // Airplane - use cached climbing
|
|
{
|
|
return 1; // Paper
|
|
}
|