1
0
Fork 0
kay27 2020-12-13 03:00:04 +04:00
commit 5da02bb8cc
103 changed files with 2949 additions and 233 deletions

View File

@ -18,7 +18,7 @@ digging times in seconds. These digging times can be then added verbatim into th
Example:
mcl_autogroup.digtimes.pickaxey_dig_diamond[1] = 0.2
This menas that when a node has been assigned the group pickaxey_dig_diamond=1, it can be dug by the
This means that when a node has been assigned the group pickaxey_dig_diamond=1, it can be dug by the
diamond pickaxe in 0.2 seconds.
@ -44,6 +44,7 @@ local divisors = {
["shearsy_wool"] = 5,
["swordy_cobweb"] = 15,
}
local max_efficiency_level = 5
mcl_autogroup = {}
mcl_autogroup.digtimes = {}
@ -53,11 +54,18 @@ for m=1, #materials do
for g=1, #basegroups do
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m]] = {}
mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m]] = {}
for e=1, max_efficiency_level do
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m].."_efficiency_"..e] = {}
end
end
end
for g=1, #minigroups do
mcl_autogroup.digtimes[minigroups[g].."_dig"] = {}
mcl_autogroup.creativetimes[minigroups[g].."_dig"] = {}
for e=1, max_efficiency_level do
mcl_autogroup.digtimes[minigroups[g].."_dig_efficiency_"..e] = {}
mcl_autogroup.creativetimes[minigroups[g].."_dig_efficiency_"..e] = {}
end
end
local overwrite = function()
@ -80,7 +88,7 @@ local overwrite = function()
groups_changed = true
end
local function calculate_group(hardness, material, diggroup, newgroups, actual_rating, expected_rating)
local function calculate_group(hardness, material, diggroup, newgroups, actual_rating, expected_rating, efficiency)
local time, validity_factor
if actual_rating >= expected_rating then
-- Valid tool
@ -89,14 +97,20 @@ local overwrite = function()
-- Wrong tool (higher digging time)
validity_factor = 5
end
time = (hardness * validity_factor) / divisors[material]
local speed_multiplier = divisors[material]
if efficiency then
speed_multiplier = speed_multiplier + efficiency * efficiency + 1
end
time = (hardness * validity_factor) / speed_multiplier
if time <= 0.05 then
time = 0
else
time = math.ceil(time * 20) / 20
end
table.insert(mcl_autogroup.digtimes[diggroup], time)
table.insert(mcl_autogroup.creativetimes[diggroup], 0)
if not efficiency then
table.insert(mcl_autogroup.creativetimes[diggroup], 0)
end
newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup]
return newgroups
end
@ -113,6 +127,9 @@ local overwrite = function()
for g=1,#materials do
local diggroup = basegroup.."_dig_"..materials[g]
newgroups = calculate_group(hardness, materials[g], diggroup, newgroups, g, ndef.groups[basegroup])
for e=1,max_efficiency_level do
newgroups = calculate_group(hardness, materials[g], diggroup .. "_efficiency_" .. e, newgroups, g, ndef.groups[basegroup], e)
end
groups_changed = true
end
end
@ -134,6 +151,9 @@ local overwrite = function()
or
(ndef.groups[minigroup] and minigroup ~= "swordy_cobweb" and minigroup ~= "shearsy_wool") then
newgroups = calculate_group(hardness, minigroup, diggroup, newgroups, ar, 1)
for e=1,max_efficiency_level do
newgroups = calculate_group(hardness, minigroup, diggroup .. "_efficiency_" .. e, newgroups, ar, 1, e)
end
groups_changed = true
end
end

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,704 @@
-- Taken from https://minecraft.gamepedia.com/Enchanting
local function increase_damage(damage_group, factor)
return function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities()
tool_capabilities.damage_groups[damage_group] = (tool_capabilities.damage_groups[damage_group] or 0) + level * factor
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
end
end
-- requires engine change
--[[mcl_enchanting.enchantments.aqua_affinity = {
name = "Aqua Affinity",
max_level = 1,
primary = {armor_head = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {},
weight = 2,
description = "Increases underwater mining speed.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 41}},
}]]--
-- implemented via on_enchant and additions in mobs_mc; Slowness IV part unimplemented
mcl_enchanting.enchantments.bane_of_arthropods = {
name = "Bane of Arthropods",
max_level = 5,
primary = {sword = true},
secondary = {axe = true},
disallow = {},
incompatible = {smite = true, shaprness = true},
weight = 5,
description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).",
curse = false,
on_enchant = increase_damage("anthropod", 2.5),
requires_tool = false,
treasure = false,
power_range_table = {{5, 25}, {13, 33}, {21, 41}, {29, 49}, {37, 57}},
}
-- implemented in mcl_armor
mcl_enchanting.enchantments.blast_protection = {
name = "Blast Protection",
max_level = 4,
primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {fire_protection = true, protection = true, projectile_protection = true},
weight = 2,
description = "Reduces explosion damage and knockback.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{5, 13}, {13, 21}, {21, 29}, {29, 37}},
}
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.channeling = {
name = "Channeling",
max_level = 1,
primary = {trident = true},
secondary = {},
disallow = {},
incompatible = {riptide = true},
weight = 1,
description = "Trident \"channels\" a bolt of lightning toward a hit entity. Functions only during thunderstorms and if target is unobstructed with opaque blocks.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{25, 50}},
}]]--
-- implemented in mcl_armor
mcl_enchanting.enchantments.curse_of_binding = {
name = "Curse of Binding",
max_level = 1,
primary = {},
secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true},
disallow = {},
incompatible = {},
weight = 1,
description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking.",
curse = true,
on_enchant = function() end,
requires_tool = false,
treasure = true,
power_range_table = {{25, 50}},
}
-- implemented in mcl_death_drop
mcl_enchanting.enchantments.curse_of_vanishing = {
name = "Curse of Vanishing",
max_level = 1,
primary = {},
secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true},
disallow = {},
incompatible = {},
weight = 1,
description = "Item destroyed on death.",
curse = true,
on_enchant = function() end,
requires_tool = false,
treasure = true,
power_range_table = {{25, 50}},
}
-- unimplemented
--[[mcl_enchanting.enchantments.depth_strider = {
name = "Depth Strider",
max_level = 3,
primary = {},
secondary = {armor_feet = true},
disallow = {non_combat_armor = true},
incompatible = {frost_walker = true},
weight = 2,
description = "Increases underwater movement speed.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{10, 25}, {20, 35}, {30, 45}},
}]]--
-- implemented via on_enchant
mcl_enchanting.enchantments.efficiency = {
name = "Efficiency",
max_level = 5,
primary = {pickaxe = true, shovel = true, axe = true, hoe = true},
secondary = {shears = true},
disallow = {},
incompatible = {},
weight = 10,
description = "Increases mining speed.",
curse = false,
on_enchant = function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities()
local groupcaps = {}
for group, capability in pairs(tool_capabilities.groupcaps) do
local groupname = group .. "_efficiency_" .. level
capability.times = mcl_autogroup.digtimes[groupname]
groupcaps[groupname] = capability
end
tool_capabilities.groupcaps = groupcaps
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 61}, {11, 71}, {21, 81}, {31, 91}, {41, 101}},
}
-- implemented in mcl_armor
mcl_enchanting.enchantments.feather_falling = {
name = "Feather Falling",
max_level = 4,
primary = {armor_feet = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {},
weight = 5,
description = "Reduces fall damage.",curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{5, 11}, {11, 17}, {17, 23}, {23, 29}},
}
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.fire_aspect = {
name = "Fire Aspect",
max_level = 2,
primary = {sword = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Sets target on fire.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{10, 61}, {30, 71}},
}]]--
-- implemented in mcl_armor
mcl_enchanting.enchantments.fire_protection = {
name = "Fire Protection",
max_level = 4,
primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {blast_protection = true, protection = true, projectile_protection = true},
weight = 5,
description = "Reduces fire damage.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{10, 18}, {18, 26}, {26, 34}, {34, 42}},
}
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.flame = {
name = "Flame",
max_level = 1,
primary = {bow = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Arrows set target on fire.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{20, 50}},
}]]--
-- implemented in mcl_item_entity
mcl_enchanting.enchantments.fortune = {
name = "Fortune",
max_level = 3,
primary = {pickaxe = true, shovel = true, axe = true, hoe = true},
secondary = {},
disallow = {},
incompatible = {silk_touch = true},
weight = 2,
description = "Increases certain block drops.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
}
-- implemented via walkover.register_global
mcl_enchanting.enchantments.frost_walker = {
name = "Frost Walker",
max_level = 2,
primary = {},
secondary = {armor_feet = true},
disallow = {non_combat_armor = true},
incompatible = {depth_strider = true},
weight = 2,
description = "Turns water beneath the player into frosted ice and prevents the damage the player would take from standing on magma blocks.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = true,
power_range_table = {{10, 25}, {20, 35}},
}
walkover.register_global(function(pos, _, player)
local boots = player:get_inventory():get_stack("armor", 5)
local frost_walker = mcl_enchanting.get_enchantment(boots, "frost_walker")
if frost_walker <= 0 then
return
end
local radius = frost_walker + 2
local minp = {x = pos.x - radius, y = pos.y, z = pos.z - radius}
local maxp = {x = pos.x + radius, y = pos.y, z = pos.z + radius}
local positions = minetest.find_nodes_in_area_under_air(minp, maxp, "mcl_core:water_source")
for _, p in ipairs(positions) do
if vector.distance(pos, p) <= radius then
minetest.set_node(p, {name = "mcl_core:frosted_ice_0"})
end
end
end)
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.impaling = {
name = "Impaling",
max_level = 5,
primary = {trident = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Trident deals additional damage to mobs that spawn naturally in the ocean.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 21}, {9, 29}, {17, 37}, {25, 45}, {33, 53}},
}]]--
-- implemented in mcl_bows
mcl_enchanting.enchantments.infinity = {
name = "Infinity",
max_level = 1,
primary = {bow = true},
secondary = {},
disallow = {},
incompatible = {mending = true},
weight = 1,
description = "Shooting consumes no regular arrows.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{20, 50}},
}
-- implemented via minetest.calculate_knockback
mcl_enchanting.enchantments.knockback = {
name = "Knockback",
max_level = 2,
primary = {sword = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 5,
description = "Increases knockback.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{5, 61}, {25, 71}},
}
local old_calculate_knockback = minetest.calculate_knockback
function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
local knockback = old_calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
local luaentity
if hitter then
luaentity = hitter:get_luaentity()
end
if hitter and hitter:is_player() then
local wielditem = hitter:get_wielded_item()
knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
elseif luaentity and luaentity._knockback then
knockback = knockback + luaentity._knockback
end
return knockback
end
-- unimplemented
--[[mcl_enchanting.enchantments.looting = {
name = "Looting",
max_level = 3,
primary = {sword = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Increases mob loot.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
}]]--
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.loyalty = {
name = "Loyalty",
max_level = 3,
primary = {trident = true},
secondary = {},
disallow = {},
incompatible = {riptide = true},
weight = 5,
description = "Trident returns after being thrown. Higher levels reduce return time.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{12, 50}, {19, 50}, {26, 50}},
}]]--
-- unimplemented
--[[mcl_enchanting.enchantments.luck_of_the_sea = {
name = "Luck of the Sea",
max_level = 3,
primary = {fishing_rod = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Increases rate of good loot (enchanting books, etc.)",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
}]]--
-- implemented in mcl_fishing
mcl_enchanting.enchantments.lure = {
name = "Lure",
max_level = 3,
primary = {fishing_rod = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Decreases wait time until fish/junk/loot \"bites\".",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
}
-- unimplemented
--[[mcl_enchanting.enchantments.mending = {
name = "Mending",
max_level = 1,
primary = {},
secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true},
disallow = {},
incompatible = {infinity = true},
weight = 2,
description = "Repair the item while gaining XP orbs.",
curse = false,
on_enchant = function() end,
requires_tool = true,
treasure = true,
power_range_table = {{25, 75}},
}]]--
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.multishot = {
name = "Multishot",
max_level = 1,
primary = {crossbow = true},
secondary = {},
disallow = {},
incompatible = {piercing = true},
weight = 2,
description = "Shoot 3 arrows at the cost of one.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{20, 50}},
}]]--
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.piercing = {
name = "Piercing",
max_level = 4,
primary = {crossbow = true},
secondary = {},
disallow = {},
incompatible = {multishot = true},
weight = 10,
description = "Arrows pass through multiple entities.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 50}, {11, 50}, {21, 50}, {31, 50}},
}]]--
-- implemented in mcl_bows
mcl_enchanting.enchantments.power = {
name = "Power",
max_level = 5,
primary = {bow = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 10,
description = "Increases arrow damage.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}},
}
-- implemented in mcl_armor
mcl_enchanting.enchantments.projectile_protection = {
name = "Projectile Protection",
max_level = 4,
primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {blast_protection = true, fire_protection = true, protection = true},
weight = 5,
description = "Reduces projectile damage.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}},
}
-- implemented in mcl_armor
mcl_enchanting.enchantments.protection = {
name = "Protection",
max_level = 4,
primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true},
weight = 10,
description = "Reduces most types of damage by 4% for each level.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{1, 12}, {12, 23}, {23, 34}, {34, 45}},
}
-- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows
mcl_enchanting.enchantments.punch = {
name = "Punch",
max_level = 2,
primary = {},
secondary = {bow = true},
disallow = {},
incompatible = {},
weight = 2,
description = "Increases arrow knockback.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{12, 37}, {32, 57}},
}
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.quick_charge = {
name = "Quick Charge",
max_level = 3,
primary = {crossbow = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 5,
description = "Decreases crossbow charging time.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{12, 50}, {32, 50}, {52, 50}},
}]]--
-- unimplemented
--[[mcl_enchanting.enchantments.respiration = {
name = "Respiration",
max_level = 3,
primary = {armor_head = true},
secondary = {},
disallow = {non_combat_armor = true},
incompatible = {},
weight = 2,
description = "Extends underwater breathing time.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{10, 40}, {20, 50}, {30, 60}},
}]]--
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.riptide = {
name = "Riptide",
max_level = 3,
primary = {trident = true},
secondary = {},
disallow = {},
incompatible = {channeling = true, loyalty = true},
weight = 2,
description = "Trident launches player with itself when thrown. Functions only in water or rain.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{17, 50}, {24, 50}, {31, 50}},
}]]--
-- implemented via on_enchant
mcl_enchanting.enchantments.sharpness = {
name = "Sharpness",
max_level = 5,
primary = {sword = true},
secondary = {axe = true},
disallow = {},
incompatible = {bane_of_arthropods = true, smite = true},
weight = 5,
description = "Increases damage.",
curse = false,
on_enchant = increase_damage("fleshy", 0.5),
requires_tool = false,
treasure = false,
power_range_table = {{1, 21}, {12, 32}, {23, 43}, {34, 54}, {45, 65}},
}
-- implemented in mcl_item_entity
mcl_enchanting.enchantments.silk_touch = {
name = "Silk Touch",
max_level = 1,
primary = {pickaxe = true, shovel = true, axe = true, hoe = true},
secondary = {shears = true},
disallow = {},
incompatible = {fortune = true},
weight = 1,
description = "Mined blocks drop themselves.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{15, 61}},
}
-- implemented via on_enchant and additions in mobs_mc
mcl_enchanting.enchantments.smite = {
name = "Smite",
max_level = 5,
primary = {sword = true},
secondary = {axe = true},
disallow = {},
incompatible = {bane_of_arthropods = true, sharpness = true},
weight = 5,
description = "Increases damage to undead mobs.",
curse = false,
on_enchant = increase_damage("undead", 2.5),
requires_tool = false,
treasure = false,
power_range_table = {{5, 25}, {13, 33}, {21, 41}, {29, 49}, {37, 57}},
}
-- implemented in mcl_playerplus
mcl_enchanting.enchantments.soul_speed = {
name = "Soul Speed",
max_level = 3,
primary = {},
secondary = {armor_feet = true},
disallow = {non_combat_armor = true},
incompatible = {frost_walker = true},
weight = 2,
description = "Increases walking speed on soul sand.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = true,
power_range_table = {{10, 25}, {20, 35}, {30, 45}},
}
-- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.sweeping_edge = {
name = "Sweeping Edge",
max_level = 3,
primary = {sword = true},
secondary = {},
disallow = {},
incompatible = {},
weight = 2,
description = "Increases sweeping attack damage.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{5, 20}, {14, 29}, {23, 38}},
}]]--
-- implemented in mcl_armor
mcl_enchanting.enchantments.thorns = {
name = "Thorns",
max_level = 3,
primary = {armor_head = true},
secondary = {armor_torso = true, armor_legs = true, armor_feet = true},
disallow = {non_combat_armor = true},
incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true},
weight = 1,
description = "Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.",
curse = false,
on_enchant = function() end,
requires_tool = false,
treasure = false,
power_range_table = {{10, 61}, {30, 71}, {50, 81}},
}
-- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows; for armor implemented in mcl_armor and mcl_tt; for fishing rods implemented in mcl_fishing
mcl_enchanting.enchantments.unbreaking = {
name = "Unbreaking",
max_level = 3,
primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, pickaxe = true, shovel = true, axe = true, hoe = true, sword = true, fishing_rod = true, bow = true},
secondary = {tool = true},
disallow = {non_combat_armor = true},
incompatible = {},
weight = 5,
description = "Increases item durability.",
curse = false,
on_enchant = function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities()
for group, capability in pairs(tool_capabilities.groupcaps) do
capability.uses = capability.uses * (1 + level)
end
tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level)
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
end,
requires_tool = true,
treasure = false,
power_range_table = {{5, 61}, {13, 71}, {21, 81}},
}

View File

@ -0,0 +1,599 @@
function mcl_enchanting.is_book(itemname)
return itemname == "mcl_books:book" or itemname == "mcl_enchanting:book_enchanted"
end
function mcl_enchanting.get_enchantments(itemstack)
return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {}
end
function mcl_enchanting.set_enchantments(itemstack, enchantments)
itemstack:get_meta():set_string("mcl_enchanting:enchantments", minetest.serialize(enchantments))
local itemdef = itemstack:get_definition()
if not mcl_enchanting.is_book(itemstack:get_name()) then
if itemdef.tool_capabilities then
itemstack:get_meta():set_tool_capabilities(itemdef.tool_capabilities)
end
for enchantment, level in pairs(enchantments) do
local enchantment_def = mcl_enchanting.enchantments[enchantment]
if enchantment_def.on_enchant then
enchantment_def.on_enchant(itemstack, level)
end
end
end
tt.reload_itemstack_description(itemstack)
end
function mcl_enchanting.get_enchantment(itemstack, enchantment)
return mcl_enchanting.get_enchantments(itemstack)[enchantment] or 0
end
function mcl_enchanting.has_enchantment(itemstack, enchantment)
return mcl_enchanting.get_enchantment(itemstack, enchantment) > 0
end
function mcl_enchanting.get_enchantment_description(enchantment, level)
local enchantment_def = mcl_enchanting.enchantments[enchantment]
return enchantment_def.name .. (enchantment_def.max_level == 1 and "" or " " .. mcl_enchanting.roman_numerals.toRoman(level))
end
function mcl_enchanting.get_colorized_enchantment_description(enchantment, level)
return minetest.colorize(mcl_enchanting.enchantments[enchantment].curse and "#FC5454" or "#A8A8A8", mcl_enchanting.get_enchantment_description(enchantment, level))
end
function mcl_enchanting.get_enchanted_itemstring(itemname)
local def = minetest.registered_items[itemname]
return def and def._mcl_enchanting_enchanted_tool
end
function mcl_enchanting.set_enchanted_itemstring(itemstack)
itemstack:set_name(mcl_enchanting.get_enchanted_itemstring(itemstack:get_name()))
end
function mcl_enchanting.is_enchanted(itemname)
return minetest.get_item_group(itemname, "enchanted") > 0
end
function mcl_enchanting.is_enchantable(itemname)
return mcl_enchanting.get_enchantability(itemname) > 0
end
function mcl_enchanting.can_enchant_freshly(itemname)
return mcl_enchanting.is_enchantable(itemname) and not mcl_enchanting.is_enchanted(itemname)
end
function mcl_enchanting.get_enchantability(itemname)
return minetest.get_item_group(itemname, "enchantability")
end
function mcl_enchanting.item_supports_enchantment(itemname, enchantment, early)
if not mcl_enchanting.is_enchantable(itemname) then
return false
end
local enchantment_def = mcl_enchanting.enchantments[enchantment]
if mcl_enchanting.is_book(itemname) then
return true, (not enchantment_def.treasure)
end
local itemdef = minetest.registered_items[itemname]
if itemdef.type ~= "tool" and enchantment_def.requires_tool then
return false
end
for disallow in pairs(enchantment_def.disallow) do
if minetest.get_item_group(itemname, disallow) > 0 then
return false
end
end
for group in pairs(enchantment_def.primary) do
if minetest.get_item_group(itemname, group) > 0 then
return true, true
end
end
for group in pairs(enchantment_def.secondary) do
if minetest.get_item_group(itemname, group) > 0 then
return true, false
end
end
return false
end
function mcl_enchanting.can_enchant(itemstack, enchantment, level)
local enchantment_def = mcl_enchanting.enchantments[enchantment]
if not enchantment_def then
return false, "enchantment invalid"
end
local itemname = itemstack:get_name()
if itemname == "" then
return false, "item missing"
end
local supported, primary = mcl_enchanting.item_supports_enchantment(itemstack:get_name(), enchantment)
if not supported then
return false, "item not supported"
end
if not level then
return false, "level invalid"
end
if level > enchantment_def.max_level then
return false, "level too high", enchantment_def.max_level
elseif level < 1 then
return false, "level too small", 1
end
local item_enchantments = mcl_enchanting.get_enchantments(itemstack)
local enchantment_level = item_enchantments[enchantment]
if enchantment_level then
return false, "incompatible", mcl_enchanting.get_enchantment_description(enchantment, enchantment_level)
end
if not mcl_enchanting.is_book(itemname) then
for incompatible in pairs(enchantment_def.incompatible) do
local incompatible_level = item_enchantments[incompatible]
if incompatible_level then
return false, "incompatible", mcl_enchanting.get_enchantment_description(incompatible, incompatible_level)
end
end
end
return true, nil, nil, primary
end
function mcl_enchanting.enchant(itemstack, enchantment, level)
mcl_enchanting.set_enchanted_itemstring(itemstack)
local enchantments = mcl_enchanting.get_enchantments(itemstack)
enchantments[enchantment] = level
mcl_enchanting.set_enchantments(itemstack, enchantments)
return itemstack
end
function mcl_enchanting.combine(itemstack, combine_with)
local itemname = itemstack:get_name()
local combine_name = combine_with:get_name()
local enchanted_itemname = mcl_enchanting.get_enchanted_itemstring(itemname)
if enchanted_itemname ~= mcl_enchanting.get_enchanted_itemstring(combine_name) and not mcl_enchanting.is_book(itemname) then
return false
end
local enchantments = mcl_enchanting.get_enchantments(itemstack)
for enchantment, combine_level in pairs(mcl_enchanting.get_enchantments(combine_with)) do
local enchantment_def = mcl_enchanting.enchantments[enchantment]
local enchantment_level = enchantments[enchantment]
if enchantment_level then
if enchantment_level == combine_level then
enchantment_level = math.min(enchantment_level + 1, enchantment_def.max_level)
else
enchantment_level = math.max(enchantment_level, combine_level)
end
elseif mcl_enchanting.item_supports_enchantment(itemname, enchantment) then
local supported = true
for incompatible in pairs(enchantment_def.incompatible) do
if enchantments[incompatible] then
supported = false
break
end
end
if supported then
enchantment_level = combine_level
end
end
if enchantment_level and enchantment_level > 0 then
enchantments[enchantment] = enchantment_level
end
end
local any_enchantment = false
for enchantment, enchantment_level in pairs(enchantments) do
if enchantment_level > 0 then
any_enchantment = true
break
end
end
if any_enchantment then
itemstack:set_name(enchanted_itemname)
end
mcl_enchanting.set_enchantments(itemstack, enchantments)
return true
end
function mcl_enchanting.enchantments_snippet(_, _, itemstack)
if not itemstack then
return
end
local enchantments = mcl_enchanting.get_enchantments(itemstack)
local text = ""
for enchantment, level in pairs(enchantments) do
text = text .. mcl_enchanting.get_colorized_enchantment_description(enchantment, level) .. "\n"
end
if text ~= "" then
if not itemstack:get_definition()._tt_original_description then
text = text:sub(1, text:len() - 1)
end
return text, false
end
end
function mcl_enchanting.initialize()
local register_tool_list = {}
local register_item_list = {}
for itemname, itemdef in pairs(minetest.registered_items) do
if mcl_enchanting.can_enchant_freshly(itemname) then
local new_name = itemname .. "_enchanted"
minetest.override_item(itemname, {_mcl_enchanting_enchanted_tool = new_name})
local new_def = table.copy(itemdef)
new_def.inventory_image = itemdef.inventory_image .. mcl_enchanting.overlay
if new_def.wield_image then
new_def.wield_image = new_def.wield_image .. mcl_enchanting.overlay
end
new_def.groups.not_in_creative_inventory = 1
new_def.groups.enchanted = 1
new_def.texture = itemdef.texture or itemname:gsub("%:", "_")
new_def._mcl_enchanting_enchanted_tool = new_name
local register_list = register_item_list
if itemdef.type == "tool" then
register_list = register_tool_list
end
register_list[":" .. new_name] = new_def
end
end
for new_name, new_def in pairs(register_item_list) do
minetest.register_craftitem(new_name, new_def)
end
for new_name, new_def in pairs(register_tool_list) do
minetest.register_tool(new_name, new_def)
end
end
function mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure)
local possible_enchantments, weights, accum_weight = {}, {}, 0
for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do
local supported, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1)
if primary or treasure then
table.insert(possible_enchantments, enchantment)
accum_weight = accum_weight + enchantment_def.weight
weights[enchantment] = accum_weight
end
end
return possible_enchantments, weights, accum_weight
end
function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance)
local itemname = itemstack:get_name()
if not mcl_enchanting.can_enchant_freshly(itemname) then
return
end
itemstack = ItemStack(itemstack)
local enchantability = minetest.get_item_group(itemname, "enchantability")
enchantability = 1 + math.random(0, math.floor(enchantability / 4)) + math.random(0, math.floor(enchantability / 4))
enchantment_level = enchantment_level + enchantability
enchantment_level = enchantment_level + enchantment_level * (math.random() + math.random() - 1) * 0.15
enchantment_level = math.max(math.floor(enchantment_level + 0.5), 1)
local enchantments = {}
local description
enchantment_level = enchantment_level * 2
repeat
enchantment_level = math.floor(enchantment_level / 2)
if enchantment_level == 0 then
break
end
local possible, weights, accum_weight = mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure)
local selected_enchantment, enchantment_power
if #possible > 0 then
local r = math.random(accum_weight)
for _, enchantment in ipairs(possible) do
if weights[enchantment] >= r then
selected_enchantment = enchantment
break
end
end
local enchantment_def = mcl_enchanting.enchantments[selected_enchantment]
local power_range_table = enchantment_def.power_range_table
for i = enchantment_def.max_level, 1, -1 do
local power_range = power_range_table[i]
if enchantment_level >= power_range[1] and enchantment_level <= power_range[2] then
enchantment_power = i
break
end
end
if not description then
if not enchantment_power then
return
end
description = mcl_enchanting.get_enchantment_description(selected_enchantment, enchantment_power)
end
if enchantment_power then
enchantments[selected_enchantment] = enchantment_power
mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power)
end
else
break
end
until not no_reduced_bonus_chance and math.random() >= (enchantment_level + 1) / 50
return enchantments, description
end
function mcl_enchanting.enchant_randomly(itemstack, enchantment_level, treasure, no_reduced_bonus_chance)
local enchantments = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance)
if enchantments then
mcl_enchanting.set_enchanted_itemstring(itemstack)
mcl_enchanting.set_enchantments(itemstack, enchantments)
end
return itemstack
end
function mcl_enchanting.get_randomly_enchanted_book(enchantment_level, treasure, no_reduced_bonus_chance)
return mcl_enchanting.enchant_randomly(enchantment_level, treasure, no_reduced_bonus_chance)
end
function mcl_enchanting.get_random_glyph_row()
local glyphs = ""
local x = 1.3
for i = 1, 9 do
glyphs = glyphs .. "image[".. x .. ",0.1;0.5,0.5;mcl_enchanting_glyph_" .. math.random(18) .. ".png^[colorize:#675D49:255]"
x = x + 0.6
end
return glyphs
end
function mcl_enchanting.generate_random_table_slots(itemstack, num_bookshelves)
local base = math.random(8) + math.floor(num_bookshelves / 2) + math.random(0, num_bookshelves)
local required_levels = {
math.max(base / 3, 1),
(base * 2) / 3 + 1,
math.max(base, num_bookshelves * 2)
}
local slots = {}
for i, enchantment_level in ipairs(required_levels) do
local slot = false
local enchantments, description = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level)
if enchantments then
slot = {
enchantments = enchantments,
description = description,
glyphs = mcl_enchanting.get_random_glyph_row(),
level_requirement = math.max(i, math.floor(enchantment_level)),
}
end
slots[i] = slot
end
return slots
end
function mcl_enchanting.get_table_slots(player, itemstack, num_bookshelves)
if not mcl_enchanting.can_enchant_freshly(itemstack:get_name()) then
return {false, false, false}
end
local itemname = itemstack:get_name()
local meta = player:get_meta()
local player_slots = minetest.deserialize(meta:get_string("mcl_enchanting:slots")) or {}
local player_bookshelves_slots = player_slots[num_bookshelves] or {}
local player_bookshelves_item_slots = player_bookshelves_slots[itemname]
if player_bookshelves_item_slots then
return player_bookshelves_item_slots
else
player_bookshelves_item_slots = mcl_enchanting.generate_random_table_slots(itemstack, num_bookshelves)
if player_bookshelves_item_slots then
player_bookshelves_slots[itemname] = player_bookshelves_item_slots
player_slots[num_bookshelves] = player_bookshelves_slots
meta:set_string("mcl_enchanting:slots", minetest.serialize(player_slots))
return player_bookshelves_item_slots
else
return {false, false, false}
end
end
end
function mcl_enchanting.reset_table_slots(player)
player:get_meta():set_string("mcl_enchanting:slots", "")
end
function mcl_enchanting.show_enchanting_formspec(player)
local C = minetest.get_color_escape_sequence
local name = player:get_player_name()
local meta = player:get_meta()
local inv = player:get_inventory()
local num_bookshelves = meta:get_int("mcl_enchanting:num_bookshelves")
local table_name = meta:get_string("mcl_enchanting:table_name")
local formspec = ""
.. "size[9.07,8.6;]"
.. "formspec_version[3]"
.. "label[0,0;" .. C("#313131") .. table_name .. "]"
.. mcl_formspec.get_itemslot_bg(0.2, 2.4, 1, 1)
.. "list[detached:" .. name .. "_enchanting;enchanting;0.2,2.4;1,1;1]"
.. mcl_formspec.get_itemslot_bg(1.1, 2.4, 1, 1)
.. "image[1.1,2.4;1,1;mcl_enchanting_lapis_background.png]"
.. "list[detached:" .. name .. "_enchanting;enchanting;1.1,2.4;1,1;2]"
.. "label[0,4;" .. C("#313131") .. "Inventory]"
.. mcl_formspec.get_itemslot_bg(0, 4.5, 9, 3)
.. mcl_formspec.get_itemslot_bg(0, 7.74, 9, 1)
.. "list[current_player;main;0,4.5;9,3;9]"
.. "listring[detached:" .. name .. "_enchanting;enchanting]"
.. "listring[current_player;main]"
.. "list[current_player;main;0,7.74;9,1;]"
.. "real_coordinates[true]"
.. "image[3.15,0.6;7.6,4.1;mcl_enchanting_button_background.png]"
local itemstack = inv:get_stack("enchanting_item", 1)
local player_levels = mcl_experience.get_player_xp_level(player)
local y = 0.65
local any_enchantment = false
local table_slots = mcl_enchanting.get_table_slots(player, itemstack, num_bookshelves)
for i, slot in ipairs(table_slots) do
any_enchantment = any_enchantment or slot
local enough_lapis = inv:contains_item("enchanting_lapis", ItemStack({name = "mcl_dye:blue", count = i}))
local enough_levels = slot and slot.level_requirement <= player_levels
local can_enchant = (slot and enough_lapis and enough_levels)
local ending = (can_enchant and "" or "_off")
local hover_ending = (can_enchant and "_hovered" or "_off")
formspec = formspec
.. "container[3.2," .. y .. "]"
.. (slot and "tooltip[button_" .. i .. ";" .. C("#818181") .. slot.description .. " " .. C("#FFFFFF") .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and "#818181" or "#FC5454") .. i .. " Lapis Lazuli\n" .. C("#818181") .. i .. " Enchantment Levels" or C("#FC5454") .. "Level Requirement: " .. slot.level_requirement) .. "]" or "")
.. "style[button_" .. i .. ";bgimg=mcl_enchanting_button" .. ending .. ".png;bgimg_hovered=mcl_enchanting_button" .. hover_ending .. ".png;bgimg_pressed=mcl_enchanting_button" .. hover_ending .. ".png]"
.. "button[0,0;7.5,1.3;button_" .. i .. ";]"
.. (slot and "image[0,0;1.3,1.3;mcl_enchanting_number_" .. i .. ending .. ".png]" or "")
.. (slot and "label[7.2,1.1;" .. C(can_enchant and "#80FF20" or "#407F10") .. slot.level_requirement .. "]" or "")
.. (slot and slot.glyphs or "")
.. "container_end[]"
y = y + 1.35
end
formspec = formspec
.. "image[" .. (any_enchantment and 0.58 or 1.15) .. ",1.2;" .. (any_enchantment and 2 or 0.87) .. ",1.43;mcl_enchanting_book_" .. (any_enchantment and "open" or "closed") .. ".png]"
minetest.show_formspec(name, "mcl_enchanting:table", formspec)
end
function mcl_enchanting.handle_formspec_fields(player, formname, fields)
if formname == "mcl_enchanting:table" then
local button_pressed
for i = 1, 3 do
if fields["button_" .. i] then
button_pressed = i
end
end
if not button_pressed then return end
local name = player:get_player_name()
local inv = player:get_inventory()
local meta = player:get_meta()
local num_bookshelfes = meta:get_int("mcl_enchanting:num_bookshelves")
local itemstack = inv:get_stack("enchanting_item", 1)
local cost = ItemStack({name = "mcl_dye:blue", count = button_pressed})
if not inv:contains_item("enchanting_lapis", cost) then
return
end
local slots = mcl_enchanting.get_table_slots(player, itemstack, num_bookshelfes)
local slot = slots[button_pressed]
if not slot then
return
end
local player_level = mcl_experience.get_player_xp_level(player)
if player_level < slot.level_requirement then
return
end
mcl_experience.set_player_xp_level(player, player_level - button_pressed)
inv:remove_item("enchanting_lapis", cost)
mcl_enchanting.set_enchanted_itemstring(itemstack)
mcl_enchanting.set_enchantments(itemstack, slot.enchantments)
inv:set_stack("enchanting_item", 1, itemstack)
minetest.sound_play("mcl_enchanting_enchant", {to_player = name, gain = 5.0})
mcl_enchanting.reset_table_slots(player)
mcl_enchanting.reload_inventory(player)
mcl_enchanting.show_enchanting_formspec(player)
end
end
function mcl_enchanting.initialize_player(player)
local player_inv = player:get_inventory()
player_inv:set_size("enchanting_lapis", 1)
player_inv:set_size("enchanting_item", 1)
local name = player:get_player_name()
local detached_inv = minetest.create_detached_inventory(name .. "_enchanting", {
allow_put = function(inv, listname, index, stack, player)
if player:get_player_name() ~= name then
return 0
end
if stack:get_name() == "mcl_dye:blue" and index ~= 2 then
return math.min(inv:get_stack(listname, 3):get_free_space(), stack:get_count())
elseif index ~= 3 and inv:get_stack(listname, 2):get_count() == 0 then
return 1
else
return 0
end
end,
allow_take = function(inv, listname, index, stack, player)
if player:get_player_name() ~= name or index == 1 then
return 0
end
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
on_put = function(inv, listname, index, stack, player)
local result_list
if index == 1 then
if stack:get_name() == "mcl_dye:blue" then
result_list = "lapis"
stack:add_item(inv:get_stack(listname, 3))
inv:set_stack(listname, 1, nil)
inv:set_stack(listname, 3, stack)
else
result_list = "item"
inv:set_stack(listname, 1, nil)
inv:set_stack(listname, 2, stack)
end
elseif index == 2 then
result_list = "item"
elseif index == 3 then
result_list = "lapis"
stack = inv:get_stack(listname, 3)
end
player:get_inventory():set_stack("enchanting_" .. result_list, 1, stack)
mcl_enchanting.show_enchanting_formspec(player)
end,
on_take = function(inv, listname, index, stack, player)
local result_list
if index == 2 then
result_list = "item"
elseif index == 3 then
result_list = "lapis"
end
player:get_inventory():set_stack("enchanting_" .. result_list, 1, nil)
mcl_enchanting.show_enchanting_formspec(player)
end
}, name)
detached_inv:set_size("enchanting", 3)
mcl_enchanting.reload_inventory(player)
end
function mcl_enchanting.reload_inventory(player)
local player_inv = player:get_inventory()
local detached_inv = minetest.get_inventory({type = "detached", name = player:get_player_name() .. "_enchanting"})
detached_inv:set_stack("enchanting", 2, player_inv:get_stack("enchanting_item", 1))
detached_inv:set_stack("enchanting", 3, player_inv:get_stack("enchanting_lapis", 1))
end
function mcl_enchanting.schedule_book_animation(self, anim)
self.scheduled_anim = {timer = self.anim_length, anim = anim}
end
function mcl_enchanting.set_book_animation(self, anim)
local anim_index = mcl_enchanting.book_animations[anim]
local start, stop = mcl_enchanting.book_animation_steps[anim_index], mcl_enchanting.book_animation_steps[anim_index + 1]
self.object:set_animation({x = start, y = stop}, mcl_enchanting.book_animation_speed)
self.scheduled_anim = nil
self.anim_length = (stop - start) / 40
end
function mcl_enchanting.check_animation_schedule(self, dtime)
local schedanim = self.scheduled_anim
if schedanim then
schedanim.timer = schedanim.timer - dtime
if schedanim.timer <= 0 then
mcl_enchanting.set_book_animation(self, schedanim.anim)
end
end
end
function mcl_enchanting.look_at(self, pos2)
local pos1 = self.object:get_pos()
local vec = vector.subtract(pos1, pos2)
local yaw = math.atan(vec.z / vec.x) - math.pi/2
yaw = yaw + (pos1.x >= pos2.x and math.pi or 0)
self.object:set_yaw(yaw + math.pi)
end
function mcl_enchanting.check_book(pos)
local obj_pos = vector.add(pos, mcl_enchanting.book_offset)
for _, obj in pairs(minetest.get_objects_inside_radius(obj_pos, 0.1)) do
local luaentity = obj:get_luaentity()
if luaentity and luaentity.name == "mcl_enchanting:book" then
if minetest.get_node(pos).name ~= "mcl_enchanting:table" then
obj:remove()
end
return
end
end
minetest.add_entity(obj_pos, "mcl_enchanting:book")
end
function mcl_enchanting.get_bookshelves(pos)
local absolute, relative = {}, {}
for i, rp in ipairs(mcl_enchanting.bookshelf_positions) do
local airp = vector.add(pos, mcl_enchanting.air_positions[i])
local ap = vector.add(pos, rp)
if minetest.get_node(ap).name == "mcl_books:bookshelf" and minetest.get_node(airp).name == "air" then
table.insert(absolute, ap)
table.insert(relative, rp)
end
end
return absolute, relative
end

View File

@ -0,0 +1,266 @@
local modpath = minetest.get_modpath("mcl_enchanting")
mcl_enchanting = {
book_offset = vector.new(0, 0.75, 0),
book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4},
book_animation_steps = {0, 640, 680, 700, 740},
book_animation_speed = 40,
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
enchantments = {},
overlay = "^[colorize:white:50^[colorize:purple:50",
bookshelf_positions = {
{x = -2, y = 0, z = -2}, {x = -2, y = 1, z = -2},
{x = -1, y = 0, z = -2}, {x = -1, y = 1, z = -2},
{x = 0, y = 0, z = -2}, {x = 0, y = 1, z = -2},
{x = 1, y = 0, z = -2}, {x = 1, y = 1, z = -2},
{x = 2, y = 0, z = -2}, {x = 2, y = 1, z = -2},
{x = -2, y = 0, z = 2}, {x = -2, y = 1, z = 2},
{x = -1, y = 0, z = 2}, {x = -1, y = 1, z = 2},
{x = 0, y = 0, z = 2}, {x = 0, y = 1, z = 2},
{x = 1, y = 0, z = 2}, {x = 1, y = 1, z = 2},
{x = 2, y = 0, z = 2}, {x = 2, y = 1, z = 2},
-- {x = -2, y = 0, z = -2}, {x = -2, y = 1, z = -2},
{x = -2, y = 0, z = -1}, {x = -2, y = 1, z = -1},
{x = -2, y = 0, z = 0}, {x = -2, y = 1, z = 0},
{x = -2, y = 0, z = 1}, {x = -2, y = 1, z = 1},
{x = -2, y = 0, z = 2}, {x = -2, y = 1, z = 2},
{x = 2, y = 0, z = -2}, {x = 2, y = 1, z = -2},
{x = 2, y = 0, z = -1}, {x = 2, y = 1, z = -1},
{x = 2, y = 0, z = 0}, {x = 2, y = 1, z = 0},
{x = 2, y = 0, z = 1}, {x = 2, y = 1, z = 1},
-- {x = 2, y = 0, z = 2}, {x = 2, y = 1, z = 2},
},
air_positions = {
{x = -1, y = 0, z = -1}, {x = -1, y = 1, z = -1},
{x = -1, y = 0, z = -1}, {x = -1, y = 1, z = -1},
{x = 0, y = 0, z = -1}, {x = 0, y = 1, z = -1},
{x = 1, y = 0, z = -1}, {x = 1, y = 1, z = -1},
{x = 1, y = 0, z = -1}, {x = 1, y = 1, z = -1},
{x = -1, y = 0, z = 1}, {x = -1, y = 1, z = 1},
{x = -1, y = 0, z = 1}, {x = -1, y = 1, z = 1},
{x = 0, y = 0, z = 1}, {x = 0, y = 1, z = 1},
{x = 1, y = 0, z = 1}, {x = 1, y = 1, z = 1},
{x = 1, y = 0, z = 1}, {x = 1, y = 1, z = 1},
-- {x = -1, y = 0, z = -1}, {x = -1, y = 1, z = -1},
{x = -1, y = 0, z = -1}, {x = -1, y = 1, z = -1},
{x = -1, y = 0, z = 0}, {x = -1, y = 1, z = 0},
{x = -1, y = 0, z = 1}, {x = -1, y = 1, z = 1},
{x = -1, y = 0, z = 1}, {x = -1, y = 1, z = 1},
{x = 1, y = 0, z = -1}, {x = 1, y = 1, z = -1},
{x = 1, y = 0, z = -1}, {x = 1, y = 1, z = -1},
{x = 1, y = 0, z = 0}, {x = 1, y = 1, z = 0},
{x = 1, y = 0, z = 1}, {x = 1, y = 1, z = 1},
-- {x = 1, y = 0, z = 1}, {x = 1, y = 1, z = 1},
},
}
dofile(modpath .. "/engine.lua")
dofile(modpath .. "/enchantments.lua")
minetest.register_chatcommand("enchant", {
description = "Enchant an item.",
params = "<player> <enchantment> [<level>]",
privs = {give = true},
func = function(_, param)
local sparam = param:split(" ")
local target_name = sparam[1]
local enchantment = sparam[2]
local level_str = sparam[3]
local level = tonumber(level_str or "1")
if not target_name or not enchantment then
return false, "Usage: /enchant <player> <enchantment> [<level>]"
end
local target = minetest.get_player_by_name(target_name)
if not target then
return false, "Player '" .. target_name .. "' cannot be found"
end
local itemstack = target:get_wielded_item()
local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level)
if not can_enchant then
if errorstring == "enchantment invalid" then
return false, "There is no such enchantment '" .. enchantment .. "'"
elseif errorstring == "item missing" then
return false, "The target doesn't hold an item"
elseif errorstring == "item not supported" then
return false, "The selected enchantment can't be added to the target item"
elseif errorstring == "level invalid" then
return false, "'" .. level_str .. "' is not a valid number"
elseif errorstring == "level too high" then
return false, "The number you have entered (" .. level_str .. ") is too big, it must be at most " .. extra_info
elseif errorstring == "level too small" then
return false, "The number you have entered (" .. level_str .. ") is too small, it must be at least " .. extra_info
elseif errorstring == "incompatible" then
return false, mcl_enchanting.get_enchantment_description(enchantment, level) .. " can't be combined with " .. extra_info
end
else
target:set_wielded_item(mcl_enchanting.enchant(itemstack, enchantment, level))
return true, "Enchanting succeded"
end
end
})
minetest.register_chatcommand("forceenchant", {
description = "Forcefully enchant an item.",
params = "<player> <enchantment> [<level>]",
func = function(_, param)
local sparam = param:split(" ")
local target_name = sparam[1]
local enchantment = sparam[2]
local level_str = sparam[3]
local level = tonumber(level_str or "1")
if not target_name or not enchantment then
return false, "Usage: /forceenchant <player> <enchantment> [<level>]"
end
local target = minetest.get_player_by_name(target_name)
if not target then
return false, "Player '" .. target_name .. "' cannot be found"
end
local itemstack = target:get_wielded_item()
local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level)
if errorstring == "enchantment invalid" then
return false, "There is no such enchantment '" .. enchantment .. "'"
elseif errorstring == "item missing" then
return false, "The target doesn't hold an item"
elseif errorstring == "item not supported" and not mcl_enchanting.is_enchantable(itemstack:get_name()) then
return false, "The target item is not enchantable"
elseif errorstring == "level invalid" then
return false, "'" .. level_str .. "' is not a valid number"
else
target:set_wielded_item(mcl_enchanting.enchant(itemstack, enchantment, level))
return true, "Enchanting succeded"
end
end
})
minetest.register_craftitem("mcl_enchanting:book_enchanted", {
description = "Enchanted Book",
inventory_image = "mcl_enchanting_book_enchanted.png" .. mcl_enchanting.overlay,
groups = {enchanted = 1, not_in_creative_inventory = 1, enchantability = 1},
_mcl_enchanting_enchanted_tool = "mcl_enchanting:book_enchanted",
stack_max = 1,
})
minetest.register_entity("mcl_enchanting:book", {
initial_properties = {
visual = "mesh",
mesh = "mcl_enchanting_book.b3d",
visual_size = {x = 12.5, y = 12.5},
collisionbox = {0, 0, 0},
physical = false,
textures = {"mcl_enchanting_book_entity.png"},
},
player_near = false,
on_activate = function(self)
self.object:set_armor_groups({immortal = 1})
mcl_enchanting.set_book_animation(self, "close")
mcl_enchanting.check_book(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset))
end,
on_step = function(self, dtime)
local old_player_near = self.player_near
local player_near = false
local player
for _, obj in ipairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do
if obj:is_player() then
player_near = true
player = obj
end
end
if player_near and not old_player_near then
mcl_enchanting.set_book_animation(self, "opening")
mcl_enchanting.schedule_book_animation(self, "open")
elseif old_player_near and not player_near then
mcl_enchanting.set_book_animation(self, "closing")
mcl_enchanting.schedule_book_animation(self, "close")
end
if player then
mcl_enchanting.look_at(self, player:get_pos())
end
self.player_near = player_near
mcl_enchanting.check_animation_schedule(self, dtime)
end,
})
minetest.register_node("mcl_enchanting:table", {
description = "Enchanting Table",
drawtype = "nodebox",
tiles = {"mcl_enchanting_table_top.png", "mcl_enchanting_table_bottom.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png"},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.25, 0.5},
},
sounds = mcl_sounds.node_sound_stone_defaults(),
groups = {pickaxey = 2},
on_rotate = (rawget(_G, "screwdriver") or {}).rotate_simple,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local player_meta = clicker:get_meta()
local table_meta = minetest.get_meta(pos)
local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves")
local table_name = table_meta:get_string("name")
if table_name == "" then
table_name = "Enchant"
end
player_meta:set_int("mcl_enchanting:num_bookshelves", num_bookshelves)
player_meta:set_string("mcl_enchanting:table_name", table_name)
mcl_enchanting.show_enchanting_formspec(clicker)
end,
on_construct = function(pos)
minetest.add_entity(vector.add(pos, mcl_enchanting.book_offset), "mcl_enchanting:book")
end,
on_destruct = function(pos)
local itemstack = ItemStack("mcl_enchanting:table")
local meta = minetest.get_meta(pos)
local itemmeta = itemstack:get_meta()
itemmeta:set_string("name", meta:get_string("name"))
itemmeta:set_string("description", meta:get_string("description"))
minetest.add_item(pos, itemstack)
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local itemmeta = itemstack:get_meta()
meta:set_string("name", itemmeta:get_string("name"))
meta:set_string("description", itemmeta:get_string("description"))
end,
after_destruct = mcl_enchanting.check_table,
drop = "",
_mcl_blast_resistance = 1200,
_mcl_hardness = 5,
})
minetest.register_craft({
output = "mcl_enchanting:table",
recipe = {
{"", "mcl_books:book", ""},
{"mcl_core:diamond", "mcl_core:obsidian", "mcl_core:diamond"},
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}
}
})
minetest.register_abm({
name = "Enchanting table bookshelf particles",
interval = 1,
chance = 1,
nodenames = "mcl_enchanting:table",
action = function(pos)
mcl_enchanting.check_book(pos)
local absolute, relative = mcl_enchanting.get_bookshelves(pos)
for i, ap in ipairs(absolute) do
if math.random(10) == 1 then
local rp = relative[i]
minetest.add_particle({
pos = ap,
velocity = vector.subtract(vector.new(0, 5, 0), rp),
acceleration = {x = 0, y = -9.81, z = 0},
expirationtime = 2,
size = 2,
texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
})
end
end
minetest.get_meta(pos):set_int("mcl_enchanting:num_bookshelves", math.min(15, #absolute))
end
})
minetest.register_on_mods_loaded(mcl_enchanting.initialize)
minetest.register_on_joinplayer(mcl_enchanting.initialize_player)
minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields)
table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet)

View File

@ -0,0 +1,5 @@
name = mcl_enchanting
description = Enchanting for MineClone2
depends = tt, walkover, mcl_sounds
optional_depends = screwdriver
author = Fleckenstein

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

View File

@ -0,0 +1,34 @@
--------------------------------------------------------------------
--! @file
--! @brief Convert from normal numbers to Roman Numerals
---------------------------------------------------------------------
local conversionTable = {
{ number = 1000, symbol = "M" },
{ number = 900, symbol = "CM" },
{ number = 500, symbol = "D" },
{ number = 400, symbol = "CD" },
{ number = 100, symbol = "C" },
{ number = 90, symbol = "XC" },
{ number = 50, symbol = "L" },
{ number = 40, symbol = "XL" },
{ number = 10, symbol = "X" },
{ number = 9, symbol = "IX" },
{ number = 5, symbol = "V" },
{ number = 4, symbol = "IV" },
{ number = 1, symbol = "I" }
}
return{
toRoman = function(number)
local romanNumeral = ""
for _,table in pairs (conversionTable) do
while(number >= table.number) do
romanNumeral = romanNumeral .. table.symbol
number = number - table.number
end
end
return romanNumeral
end
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

View File

@ -284,8 +284,14 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire,
impact = 0
end
local damage = math.floor((impact * impact + impact) * 7 * strength + 1)
if mod_death_messages and obj:is_player() then
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", obj:get_player_name()))
if obj:is_player() then
local name = obj:get_player_name()
if mod_death_messages then
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name))
end
if rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[name] = "explosion"
end
end
local source = puncher
if not source then

View File

@ -1,4 +1,11 @@
-- register extra flavours of a base nodedef
walkover = {}
walkover.registered_globals = {}
function walkover.register_global(func)
table.insert(walkover.registered_globals, func)
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime;
@ -10,11 +17,15 @@ minetest.register_globalstep(function(dtime)
if loc ~= nil then
local nodeiamon = minetest.get_node(loc)
if nodeiamon ~= nil then
local def = minetest.registered_nodes[nodeiamon.name]
if def ~= nil and def.on_walk_over ~= nil then
def.on_walk_over(loc, nodeiamon, player)
end
for _, func in ipairs(walkover.registered_globals) do
func(loc, nodeiamon, player)
end
end
end
end

View File

@ -1 +1,2 @@
flowlib
mcl_enchanting

View File

@ -212,6 +212,50 @@ local check_can_drop = function(node_name, tool_capabilities)
end
end
-- Stupid workaround to get drops from a drop table:
-- Create a temporary table in minetest.registered_nodes that contains the proper drops,
-- because unfortunately minetest.get_node_drops needs the drop table to be inside a registered node definition
-- (very ugly)
local tmp_id = 0
local function get_drops(drop, toolname, param2, paramtype2)
tmp_id = tmp_id + 1
local tmp_node_name = "mcl_item_entity:" .. tmp_id
minetest.registered_nodes[tmp_node_name] = {
name = tmp_node_name,
drop = drop,
paramtype2 = paramtype2
}
local drops = minetest.get_node_drops({name = tmp_node_name, param2 = param2}, toolname)
minetest.registered_nodes[tmp_node_name] = nil
return drops
end
local function discrete_uniform_distribution(drops, min_count, max_count, cap)
local new_drops = table.copy(drops)
for i, item in ipairs(drops) do
local new_item = ItemStack(item)
local multiplier = math.random(min_count, max_count)
if cap then
multiplier = math.min(cap, multiplier)
end
new_item:set_count(multiplier * new_item:get_count())
new_drops[i] = new_item
end
return new_drops
end
local function get_fortune_drops(fortune_drops, fortune_level)
local drop
local i = fortune_level
repeat
drop = fortune_drops[i]
i = i - 1
until drop or i < 1
return drop or {}
end
function minetest.handle_node_drops(pos, drops, digger)
-- NOTE: This function override allows digger to be nil.
-- This means there is no digger. This is a special case which allows this function to be called
@ -225,14 +269,9 @@ function minetest.handle_node_drops(pos, drops, digger)
-- Check if node will yield its useful drop by the digger's tool
local dug_node = minetest.get_node(pos)
local toolcaps
local tool
if digger ~= nil then
if mcl_experience.throw_experience then
local experience_amount = minetest.get_item_group(dug_node.name,"xp")
if experience_amount > 0 then
mcl_experience.throw_experience(pos, experience_amount)
end
end
local tool = digger:get_wielded_item()
tool = digger:get_wielded_item()
toolcaps = tool:get_tool_capabilities()
if not check_can_drop(dug_node.name, toolcaps) then
@ -240,12 +279,16 @@ function minetest.handle_node_drops(pos, drops, digger)
end
end
--[[ Special node drops when dug by shears by reading _mcl_shears_drop
--[[ Special node drops when dug by shears by reading _mcl_shears_drop or with a silk touch tool reading _mcl_silk_touch_drop
from the node definition.
Definition of _mcl_shears_drop:
* true: Drop itself when dug by shears
* table: Drop every itemstring in this table when dub by shears
Definition of _mcl_shears_drop / _mcl_silk_touch_drop:
* true: Drop itself when dug by shears / silk touch tool
* table: Drop every itemstring in this table when dug by shears _mcl_silk_touch_drop
]]
local enchantments = tool and mcl_enchanting.get_enchantments(tool, "silk_touch")
local silk_touch_drop = false
local nodedef = minetest.registered_nodes[dug_node.name]
if toolcaps ~= nil and toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
if nodedef._mcl_shears_drop == true then
@ -253,6 +296,39 @@ function minetest.handle_node_drops(pos, drops, digger)
else
drops = nodedef._mcl_shears_drop
end
elseif tool and enchantments.silk_touch and nodedef._mcl_silk_touch_drop then
silk_touch_drop = true
if nodedef._mcl_silk_touch_drop == true then
drops = { dug_node.name }
else
drops = nodedef._mcl_silk_touch_drop
end
end
if tool and nodedef._mcl_fortune_drop and enchantments.fortune then
local fortune_level = enchantments.fortune
local fortune_drop = nodedef._mcl_fortune_drop
if fortune_drop.discrete_uniform_distribution then
local min_count = fortune_drop.min_count
local max_count = fortune_drop.max_count + fortune_level * (fortune_drop.factor or 1)
local chance = fortune_drop.chance or fortune_drop.get_chance and fortune_drop.get_chance(fortune_level)
if not chance or math.random() < chance then
drops = discrete_uniform_distribution(fortune_drop.multiply and drops or fortune_drop.items, min_count, max_count, fortune_drop.cap)
elseif fortune_drop.override then
drops = {}
end
else
-- Fixed Behavior
local drop = get_fortune_drops(fortune_drops, fortune_level)
drops = get_drops(drop, tool:get_name(), dug_node.param2, nodedef.paramtype2)
end
end
if digger and mcl_experience.throw_experience and not silk_touch_drop then
local experience_amount = minetest.get_item_group(dug_node.name,"xp")
if experience_amount > 0 then
mcl_experience.throw_experience(pos, experience_amount)
end
end
for _,item in ipairs(drops) do

View File

@ -86,6 +86,9 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
-- Direct hit, no fire... just plenty of pain
hit_player = function(self, player)
if rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[player:get_player_name()] = "fireball"
end
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 5},

View File

@ -12,7 +12,7 @@ mobs:register_mob("mobs_mc:endermite", {
hp_max = 8,
xp_min = 3,
xp_max = 3,
armor = 100,
armor = {fleshy = 100, arthropod = 100},
group_attack = true,
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2},
visual = "mesh",

View File

@ -75,6 +75,9 @@ mobs:register_arrow("mobs_mc:fireball", {
velocity = 15,
hit_player = function(self, player)
if rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[player:get_player_name()] = "fireball"
end
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 6},

View File

@ -353,6 +353,7 @@ mobs:register_mob("mobs_mc:horse", horse)
-- Skeleton horse
local skeleton_horse = table.copy(horse)
skeleton_horse.breath_max = -1
skeleton_horse.armor = {undead = 100, fleshy = 100}
skeleton_horse.textures = {{"blank.png", "mobs_mc_horse_skeleton.png", "blank.png"}}
skeleton_horse.drops = {
{name = mobs_mc.items.bone,
@ -374,6 +375,7 @@ mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse)
-- Zombie horse
local zombie_horse = table.copy(horse)
zombie_horse.breath_max = -1
zombie_horse.armor = {undead = 100, fleshy = 100}
zombie_horse.textures = {{"blank.png", "mobs_mc_horse_zombie.png", "blank.png"}}
zombie_horse.drops = {
{name = mobs_mc.items.rotten_flesh,

View File

@ -14,6 +14,7 @@ mobs:register_mob("mobs_mc:silverfish", {
hp_max = 8,
xp_min = 5,
xp_max = 5,
armor = {fleshy = 100, arthropod = 100},
collisionbox = {-0.4, -0.01, -0.4, 0.4, 0.44, 0.4},
visual = "mesh",
mesh = "mobs_mc_silverfish.b3d",

View File

@ -20,6 +20,7 @@ local skeleton = {
xp_min = 6,
xp_max = 6,
breath_max = -1,
armor = {undead = 100, fleshy = 100},
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
pathfinding = 1,
group_attack = true,

View File

@ -17,6 +17,7 @@ mobs:register_mob("mobs_mc:witherskeleton", {
xp_min = 6,
xp_max = 6,
breath_max = -1,
armor = {undead = 100, fleshy = 100},
pathfinding = 1,
group_attack = true,
collisionbox = {-0.35, -0.01, -0.35, 0.35, 2.39, 0.35},

View File

@ -25,6 +25,7 @@ local spider = {
hp_max = 16,
xp_min = 5,
xp_max = 5,
armor = {fleshy = 100, arthropod = 100},
collisionbox = {-0.7, -0.01, -0.7, 0.7, 0.89, 0.7},
visual = "mesh",
mesh = "mobs_mc_spider.b3d",

View File

@ -20,7 +20,7 @@ mobs:register_mob("mobs_mc:villager_zombie", {
xp_min = 5,
xp_max = 5,
breath_max = -1,
armor = 90,
armor = {undead = 90, fleshy = 90},
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
visual = "mesh",
mesh = "mobs_mc_villager_zombie.b3d",

View File

@ -16,7 +16,7 @@ mobs:register_mob("mobs_mc:wither", {
hp_min = 300,
xp_min = 50,
xp_max = 50,
armor = 80,
armor = {undead = 80, fleshy = 80},
-- This deviates from MC Wiki's size, which makes no sense
collisionbox = {-0.9, 0.4, -0.9, 0.9, 2.45, 0.9},
visual = "mesh",

View File

@ -46,7 +46,7 @@ local zombie = {
xp_min = 5,
xp_max = 5,
breath_max = -1,
armor = 90,
armor = {undead = 90, fleshy = 90},
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
visual = "mesh",
mesh = "mobs_mc_zombie.b3d",

View File

@ -20,7 +20,7 @@ local pigman = {
xp_min = 6,
xp_max = 6,
breath_max = -1,
armor = 90,
armor = {undead = 90, fleshy = 90},
attack_type = "dogfight",
group_attack = { "mobs_mc:pigman", "mobs_mc:baby_pigman" },
damage = 9,

View File

@ -1 +1,2 @@
tt
mcl_enchanting

View File

@ -35,12 +35,12 @@ local function newline(str)
end
-- Digging capabilities of tool
tt.register_snippet(function(itemstring)
tt.register_snippet(function(itemstring, toolcaps)
local def = minetest.registered_items[itemstring]
if not def.tool_capabilities then
if not toolcaps then
return
end
local groupcaps = def.tool_capabilities.groupcaps
local groupcaps = toolcaps.groupcaps
if not groupcaps then
return
end
@ -105,8 +105,8 @@ tt.register_snippet(function(itemstring)
-- Capabilities
minestring = minestring .. capstr
-- Max. drop level
local mdl = def.tool_capabilities.max_drop_level
if not def.tool_capabilities.max_drop_level then
local mdl = toolcaps.max_drop_level
if not toolcaps.max_drop_level then
mdl = 0
end
minestring = minestring .. S("Block breaking strength: @1", mdl)
@ -114,9 +114,9 @@ tt.register_snippet(function(itemstring)
local weaponstring = ""
-- Weapon stats
if def.tool_capabilities.damage_groups then
for group, damage in pairs(def.tool_capabilities.damage_groups) do
local msg
if toolcaps.damage_groups then
for group, damage in pairs(toolcaps.damage_groups) do
local msg = ""
if group == "fleshy" then
if damage >= 0 then
msg = S("Damage: @1", damage)
@ -127,7 +127,7 @@ tt.register_snippet(function(itemstring)
weaponstring = newline(weaponstring)
weaponstring = weaponstring .. msg
end
local full_punch_interval = def.tool_capabilities.full_punch_interval
local full_punch_interval = toolcaps.full_punch_interval
if not full_punch_interval then
full_punch_interval = 1
end

View File

@ -25,7 +25,7 @@ tt.register_snippet(function(itemstring)
end
return s
end)
tt.register_snippet(function(itemstring)
tt.register_snippet(function(itemstring, _, itemstack)
local def = minetest.registered_items[itemstring]
local s = ""
local use = minetest.get_item_group(itemstring, "mcl_armor_uses")
@ -34,6 +34,12 @@ tt.register_snippet(function(itemstring)
s = s .. S("Armor points: @1", pts)
s = s .. "\n"
end
if itemstack then
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
if unbreaking > 0 then
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
end
end
if use > 0 then
s = s .. S("Armor durability: @1", use)
end

View File

@ -13,8 +13,9 @@ Once this mod had overwritten the `description` field of an item was overwritten
## `tt.register_snippet(func)`
Register a custom snippet function.
`func` is a function of the form `func(itemstring)`.
It will be called for (nearly) every itemstring.
`func` is a function of the form `func(itemstring, tool_capabilities, itemstack)`.
It will be called for (nearly) every itemstring at startup and when `tt.reload_itemstack_description` is called for an itemstack.
The `itemstack` parameter is only present when the snippet is called via `tt.reload_itemstack_description` and contains the itemstack.
Returns: Two values, the first one is required.
1st return value: A string you want to append to this item or `nil` if nothing shall be appended.
@ -29,3 +30,9 @@ tt.register_snippet(function(itemstring)
end
end)
```
## `tt.reload_itemstack_description(itemstack)`
This function will dynamically reload the itemstack description,
it becomes handy when `ìtemstack:get_meta():set_tool_capabilities(...)` was used
or if some snippets are based on metadata.

View File

@ -14,33 +14,41 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets.lua")
-- Apply item description updates
local function apply_snippets(desc, itemstring, toolcaps, itemstack)
local first = true
-- Apply snippets
for s=1, #tt.registered_snippets do
local str, snippet_color = tt.registered_snippets[s](itemstring, toolcaps, itemstack)
if snippet_color == nil then
snippet_color = tt.COLOR_DEFAULT
elseif snippet_color == false then
snippet_color = false
end
if str then
if first then
first = false
end
desc = desc .. "\n"
if snippet_color then
desc = desc .. minetest.colorize(snippet_color, str)
else
desc = desc .. str
end
end
end
return desc
end
local function should_change(itemstring, def)
return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true
end
local function append_snippets()
for itemstring, def in pairs(minetest.registered_items) do
if itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true then
local desc = def.description
local orig_desc = desc
local first = true
-- Apply snippets
for s=1, #tt.registered_snippets do
local str, snippet_color = tt.registered_snippets[s](itemstring)
if snippet_color == nil then
snippet_color = tt.COLOR_DEFAULT
elseif snippet_color == false then
snippet_color = false
end
if str then
if first then
first = false
end
desc = desc .. "\n"
if snippet_color then
desc = desc .. minetest.colorize(snippet_color, str)
else
desc = desc .. str
end
end
end
if desc ~= def.description then
if should_change(itemstring, def) then
local orig_desc = def.description
local desc = apply_snippets(orig_desc, itemstring, def.tool_capabilities, nil)
if desc ~= orig_desc then
minetest.override_item(itemstring, { description = desc, _tt_original_description = orig_desc })
end
end
@ -48,3 +56,22 @@ local function append_snippets()
end
minetest.register_on_mods_loaded(append_snippets)
tt.reload_itemstack_description = function(itemstack)
local itemstring = itemstack:get_name()
local def = itemstack:get_definition()
local meta = itemstack:get_meta()
if def and def._mcl_generate_description then
def._mcl_generate_description(itemstack)
elseif should_change(itemstring, def) and meta:get_string("name") == "" then
local toolcaps
if def.tool_capabilities then
toolcaps = itemstack:get_tool_capabilities()
end
local orig_desc = def._tt_original_description or def.description
local desc = apply_snippets(orig_desc, itemstring, toolcaps or def.tool_capabilities, itemstack)
if desc ~= orig_desc then
meta:set_string("description", desc)
end
end
end

View File

@ -5,3 +5,4 @@ _mcl_autogroup?
mcl_armor?
mcl_brewing?
mcl_potions?
mcl_enchanting

View File

@ -8,7 +8,7 @@ local mod_player = minetest.get_modpath("mcl_player") ~= nil
local mod_craftguide = minetest.get_modpath("mcl_craftguide") ~= nil
-- Returns a single itemstack in the given inventory to the main inventory, or drop it when there's no space left
local function return_item(itemstack, dropper, pos, inv)
function return_item(itemstack, dropper, pos, inv)
if dropper:is_player() then
-- Return to main inventory
if inv:room_for_item("main", itemstack) then
@ -36,9 +36,11 @@ local function return_item(itemstack, dropper, pos, inv)
end
-- Return items in the given inventory list (name) to the main inventory, or drop them if there is no space left
local function return_fields(player, name)
function return_fields(player, name)
local inv = player:get_inventory()
for i,stack in ipairs(inv:get_list(name)) do
local list = inv:get_list(name)
if not list then return end
for i,stack in ipairs(list) do
return_item(stack, player, player:get_pos(), inv)
stack:clear()
inv:set_stack(name, i, stack)
@ -137,6 +139,9 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.quit then
return_fields(player,"craft")
return_fields(player,"enchanting_lapis")
return_fields(player,"enchanting_item")
mcl_enchanting.reload_inventory(player)
if not minetest.is_creative_enabled(player:get_player_name()) and (formname == "" or formname == "main") then
set_inventory(player)
end
@ -152,6 +157,8 @@ end
-- Drop crafting grid items on leaving
minetest.register_on_leaveplayer(function(player)
return_fields(player, "craft")
return_fields(player, "enchanting_lapis")
return_fields(player, "enchanting_item")
end)
minetest.register_on_joinplayer(function(player)
@ -189,6 +196,8 @@ minetest.register_on_joinplayer(function(player)
when the server has been shutdown and the server didn't clean up the player
inventories. ]]
return_fields(player, "craft")
return_fields(player, "enchanting_item")
return_fields(player, "enchanting_lapis")
end)
if minetest.is_creative_enabled("") then

View File

@ -3,3 +3,5 @@ mcl_formspec
mcl_sounds
mcl_core?
screwdriver?
tt
mcl_enchanting

View File

@ -42,9 +42,6 @@ end
-- needs to be used up to repair the tool.
local function get_consumed_materials(tool, material)
local wear = tool:get_wear()
if wear == 0 then
return 0
end
local health = (MAX_WEAR - wear)
local matsize = material:get_count()
local materials_used = 0
@ -103,12 +100,15 @@ local function update_anvil_slots(meta)
return math.max(0, math.min(MAX_WEAR, MAX_WEAR - new_health))
end
-- Same tool twice
if input1:get_name() == input2:get_name() and def1.type == "tool" and (input1:get_wear() > 0 or input2:get_wear() > 0) then
local can_combine = mcl_enchanting.combine(input1, input2)
if can_combine then
-- Add tool health together plus a small bonus
-- TODO: Combine tool enchantments
local new_wear = calculate_repair(input1:get_wear(), input2:get_wear(), SAME_TOOL_REPAIR_BOOST)
input1:set_wear(new_wear)
if def1.type == "tool" and def2.type == "tool" then
local new_wear = calculate_repair(input1:get_wear(), input2:get_wear(), SAME_TOOL_REPAIR_BOOST)
input1:set_wear(new_wear)
end
name_item = input1
new_output = name_item
-- Tool + repair item
@ -170,23 +170,16 @@ local function update_anvil_slots(meta)
new_name = string.sub(new_name, 1, MAX_NAME_LENGTH)
-- Don't rename if names are identical
if new_name ~= old_name then
-- Save the raw name internally
meta:set_string("name", new_name)
-- Rename item
if new_name == "" then
-- Empty name
if name_item:get_definition()._mcl_generate_description then
-- _mcl_generate_description(itemstack): If defined, set custom item description of itemstack.
name_item:get_definition()._mcl_generate_description(name_item)
else
-- Otherwise, just clear description
meta:set_string("description", "")
end
tt.reload_itemstack_description(name_item)
else
-- Custom name set. Colorize it!
-- This makes the name visually different from unnamed items
meta:set_string("description", minetest.colorize(NAME_COLOR, new_name))
end
-- Save the raw name internally, too
meta:set_string("name", new_name)
new_output = name_item
elseif just_rename then
new_output = ""

View File

@ -18,6 +18,7 @@ armor = {
.."listring[current_player;craft]",
textures = {},
default_skin = "character",
last_damage_types = {},
}
if minetest.get_modpath("mcl_skins") then
@ -75,7 +76,7 @@ function armor.on_armor_use(itemstack, user, pointed_thing)
armor:update_inventory(user)
armor:play_equip_sound(itemstack_single, user)
itemstack:take_item()
elseif itemstack:get_count() <= 1 then
elseif itemstack:get_count() <= 1 and not mcl_enchanting.has_enchantment(itemstack_slot, "curse_of_binding") then
armor_inv:set_stack("armor", slot, itemstack_single)
player_inv:set_stack("armor", slot, itemstack_single)
armor:set_player_armor(user)
@ -119,7 +120,7 @@ armor.set_player_armor = function(self, player)
local textures = {}
local physics_o = {speed=1,gravity=1,jump=1}
local material = {type=nil, count=1}
local preview = armor:get_preview(name) or "character_preview.png"
local preview
for _,v in ipairs(self.elements) do
elements[v] = false
end
@ -136,8 +137,9 @@ armor.set_player_armor = function(self, player)
local level = def.groups["armor_"..k]
if level then
local texture = def.texture or item:gsub("%:", "_")
table.insert(textures, texture..".png")
preview = preview.."^"..texture.."_preview.png"
local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "")
table.insert(textures, "("..texture..".png"..enchanted_addition..")")
preview = "(player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..")"..(preview and "^"..preview or "")
armor_level = armor_level + level
items = items + 1
mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0)
@ -161,6 +163,7 @@ armor.set_player_armor = function(self, player)
end
end
end
preview = (armor:get_preview(name) or "character_preview.png")..(preview and "^"..preview or "")
if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9
end
@ -418,6 +421,9 @@ minetest.register_on_joinplayer(function(player)
end
end,
allow_take = function(inv, listname, index, stack, player)
if mcl_enchanting.has_enchantment(stack, "curse_of_binding") and not minetest.settings:get_bool("creative") then
return 0
end
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
@ -492,13 +498,16 @@ end)
minetest.register_on_player_hpchange(function(player, hp_change, reason)
local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]")
if name and hp_change < 0 then
local damage_type = armor.last_damage_types[name]
armor.last_damage_types[name] = nil
-- Armor doesn't protect from set_hp (commands like /kill),
-- falling and drowning damage.
if reason.type == "set_hp" or reason.type == "drown" or reason.type == "fall" then
if reason.type == "set_hp" then
return hp_change
end
local regular_reduction = reason.type ~= "drown" and reason.type ~= "fall"
-- Account for potion effects (armor doesn't save the target)
if reason.other == "poison" or reason.other == "harming" then
return hp_change
@ -510,13 +519,65 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
local total_points = 0
local total_toughness = 0
local epf = 0
local thorns_damage = 0
local thorns_damage_regular = 0
for i=1, 6 do
local stack = player_inv:get_stack("armor", i)
if stack:get_count() > 0 then
local enchantments = mcl_enchanting.get_enchantments(stack)
local pts = stack:get_definition().groups["mcl_armor_points"] or 0
local tough = stack:get_definition().groups["mcl_armor_toughness"] or 0
total_points = total_points + pts
total_toughness = total_toughness + tough
local protection_level = enchantments.protection or 0
if protection_level > 0 then
epf = epf + protection_level * 1
end
local blast_protection_level = enchantments.blast_protection or 0
if blast_protection_level > 0 and damage_type == "explosion" then
epf = epf + blast_protection_level * 2
end
local fire_protection_level = enchantments.fire_protection or 0
if fire_protection_level > 0 and (damage_type == "fireball" or reason.type == "node_damage" and
(reason.node == "mcl_fire:fire" or reason.node == "mcl_core:lava_source" or reason.node == "mcl_core:lava_flowing")) then
epf = epf + fire_protection_level * 2
end
local projectile_protection_level = enchantments.projectile_protection or 0
if projectile_protection_level and (damage_type == "projectile" or damage_type == "fireball") then
epf = epf + projectile_protection_level * 2
end
local feather_falling_level = enchantments.feather_falling or 0
if feather_falling_level and reason.type == "fall" then
epf = epf + feather_falling_level * 3
end
local did_thorns_damage = false
local thorns_level = enchantments.thorns or 0
if thorns_level then
if thorns_level > 10 then
thorns_damage = thorns_damage + thorns_level - 10
did_thorns_damage = true
elseif thorns_damage_regular < 4 and thorns_level * 0.15 > math.random() then
local thorns_damage_regular_new = math.min(4, thorns_damage_regular + math.random(4))
thorns_damage = thorns_damage + thorns_damage_regular_new - thorns_damage_regular
thorns_damage_regular = thorns_damage_regular_new
did_thorns_damage = true
end
end
-- Damage armor
local use = stack:get_definition().groups["mcl_armor_uses"] or 0
if use > 0 then
if use > 0 and regular_reduction then
local unbreaking_level = enchantments.unbreaking or 0
if unbreaking_level > 0 then
use = use / (0.6 + 0.4 / (unbreaking_level + 1))
end
local wear = armor_damage * math.floor(65536/use)
if did_thorns_damage then
wear = wear * 3
end
stack:add_wear(wear)
end
@ -528,19 +589,34 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
armor:set_player_armor(player)
armor:update_inventory(player)
end
local pts = stack:get_definition().groups["mcl_armor_points"] or 0
local tough = stack:get_definition().groups["mcl_armor_toughness"] or 0
total_points = total_points + pts
total_toughness = total_toughness + tough
end
end
local damage = math.abs(hp_change)
-- Damage calculation formula (from <https://minecraft.gamepedia.com/Armor#Damage_protection>)
damage = damage * (1 - math.min(20, math.max((total_points/5), total_points - damage / (2+(total_toughness/4)))) / 25)
if regular_reduction then
-- Damage calculation formula (from <https://minecraft.gamepedia.com/Armor#Damage_protection>)
damage = damage * (1 - math.min(20, math.max((total_points/5), total_points - damage / (2+(total_toughness/4)))) / 25)
end
damage = damage * (1 - (math.min(20, epf) / 25))
damage = math.floor(damage+0.5)
if reason.type == "punch" and thorns_damage > 0 then
local obj = reason.object
if obj then
local luaentity = obj:get_luaentity()
if luaentity then
local shooter = obj._shooter
if shooter then
obj = shooter
end
end
obj:punch(player, 1.0, {
full_punch_interval=1.0,
damage_groups = {fleshy = thorns_damage},
})
end
end
hp_change = -math.abs(damage)
armor.def[name].count = items

View File

@ -3,3 +3,4 @@ mcl_player
mcl_fire?
ethereal?
bakedclay?
mcl_enchanting

View File

@ -13,7 +13,7 @@ minetest.register_tool("mcl_armor:helmet_leather", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_helmet_leather.png",
groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56},
groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56, enchantability=15},
_repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_leather",
@ -28,7 +28,7 @@ minetest.register_tool("mcl_armor:helmet_iron", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_helmet_iron.png",
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166},
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166, enchantability=9 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -44,7 +44,7 @@ minetest.register_tool("mcl_armor:helmet_gold", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_helmet_gold.png",
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=78},
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=78, enchantability=25 },
_repair_material = "mcl_core:gold_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -59,7 +59,7 @@ minetest.register_tool("mcl_armor:helmet_diamond",{
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_helmet_diamond.png",
groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=364, mcl_armor_toughness=2},
groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=364, mcl_armor_toughness=2, enchantability=10 },
_repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_diamond",
@ -74,7 +74,7 @@ minetest.register_tool("mcl_armor:helmet_chain", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_helmet_chain.png",
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166},
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166, enchantability=12 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_chainmail",
@ -91,7 +91,7 @@ minetest.register_tool("mcl_armor:chestplate_leather", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_chestplate_leather.png",
groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81},
groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81, enchantability=15 },
_repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_leather",
@ -106,7 +106,7 @@ minetest.register_tool("mcl_armor:chestplate_iron", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_chestplate_iron.png",
groups = {armor_torso=1, mcl_armor_points=6, mcl_armor_uses=241},
groups = {armor_torso=1, mcl_armor_points=6, mcl_armor_uses=241, enchantability=9 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -121,7 +121,7 @@ minetest.register_tool("mcl_armor:chestplate_gold", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_chestplate_gold.png",
groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=113},
groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=113, enchantability=25 },
_repair_material = "mcl_core:gold_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -136,7 +136,7 @@ minetest.register_tool("mcl_armor:chestplate_diamond",{
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_chestplate_diamond.png",
groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=529, mcl_armor_toughness=2},
groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=529, mcl_armor_toughness=2, enchantability=10 },
_repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_diamond",
@ -151,7 +151,7 @@ minetest.register_tool("mcl_armor:chestplate_chain", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_chestplate_chain.png",
groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=241},
groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=241, enchantability=12 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_chainmail",
@ -168,7 +168,7 @@ minetest.register_tool("mcl_armor:leggings_leather", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_leggings_leather.png",
groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76},
groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76, enchantability=15 },
_repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_leather",
@ -183,7 +183,7 @@ minetest.register_tool("mcl_armor:leggings_iron", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_leggings_iron.png",
groups = {armor_legs=1, mcl_armor_points=5, mcl_armor_uses=226},
groups = {armor_legs=1, mcl_armor_points=5, mcl_armor_uses=226, enchantability=9 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -198,7 +198,7 @@ minetest.register_tool("mcl_armor:leggings_gold", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_leggings_gold.png",
groups = {armor_legs=1, mcl_armor_points=3, mcl_armor_uses=106},
groups = {armor_legs=1, mcl_armor_points=3, mcl_armor_uses=106, enchantability=25 },
_repair_material = "mcl_core:gold_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -213,7 +213,7 @@ minetest.register_tool("mcl_armor:leggings_diamond",{
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_leggings_diamond.png",
groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=496, mcl_armor_toughness=2},
groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=496, mcl_armor_toughness=2, enchantability=10 },
_repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_diamond",
@ -228,7 +228,7 @@ minetest.register_tool("mcl_armor:leggings_chain", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_leggings_chain.png",
groups = {armor_legs=1, mcl_armor_points=4, mcl_armor_uses=226},
groups = {armor_legs=1, mcl_armor_points=4, mcl_armor_uses=226, enchantability=12 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_chainmail",
@ -244,7 +244,7 @@ minetest.register_tool("mcl_armor:boots_leather", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_boots_leather.png",
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66},
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66, enchantability=15 },
_repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_leather",
@ -259,7 +259,7 @@ minetest.register_tool("mcl_armor:boots_iron", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_boots_iron.png",
groups = {armor_feet=1, mcl_armor_points=2, mcl_armor_uses=196},
groups = {armor_feet=1, mcl_armor_points=2, mcl_armor_uses=196, enchantability=9 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -274,7 +274,7 @@ minetest.register_tool("mcl_armor:boots_gold", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_boots_gold.png",
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=92},
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=92, enchantability=25 },
_repair_material = "mcl_core:gold_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_iron",
@ -289,7 +289,7 @@ minetest.register_tool("mcl_armor:boots_diamond",{
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_boots_diamond.png",
groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=430, mcl_armor_toughness=2},
groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=430, mcl_armor_toughness=2, enchantability=10 },
_repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_diamond",
@ -304,7 +304,7 @@ minetest.register_tool("mcl_armor:boots_chain", {
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usage,
inventory_image = "mcl_armor_inv_boots_chain.png",
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=196},
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=196, enchantability=12 },
_repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "mcl_armor_equip_chainmail",

View File

@ -15,7 +15,8 @@ minetest.register_craftitem("mcl_books:book", {
_doc_items_longdesc = S("Books are used to make bookshelves and book and quills."),
inventory_image = "default_book.png",
stack_max = 64,
groups = { book=1, craftitem = 1 },
groups = { book=1, craftitem = 1, enchantability = 1 },
_mcl_enchanting_enchanted_tool = "mcl_enchanting:book_enchanted",
})
if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then
@ -344,6 +345,7 @@ minetest.register_node("mcl_books:bookshelf", {
sounds = wood_sound,
_mcl_blast_resistance = 1.5,
_mcl_hardness = 1.5,
_mcl_silk_touch_drop = true,
})
minetest.register_craft({

View File

@ -239,20 +239,15 @@ ARROW_ENTITY.on_step = function(self, dtime)
end
-- Punch target object but avoid hurting enderman.
if lua then
if lua.name ~= "mobs_mc:enderman" then
damage_particles(self.object:get_pos(), self._is_critical)
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, nil)
if not lua or lua.name ~= "mobs_mc:enderman" then
if obj:is_player() and rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[obj:get_player_name()] = "projectile"
end
else
damage_particles(self.object:get_pos(), self._is_critical)
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, nil)
}, self.object:get_velocity())
end

View File

@ -33,7 +33,7 @@ local bow_load = {}
-- Another player table, this one stores the wield index of the bow being charged
local bow_index = {}
mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical)
mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack)
local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity")
if power == nil then
power = BOW_MAX_SPEED --19
@ -41,6 +41,16 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
if damage == nil then
damage = 3
end
local knockback
if bow_stack then
local enchantments = mcl_enchanting.get_enchantments(bow_stack)
if enchantments.power then
damage = damage + (enchantments.power + 1) / 4
end
if enchantments.punch then
knockback = enchantments.punch * 3
end
end
obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power})
obj:set_acceleration({x=0, y=-GRAVITY, z=0})
obj:set_yaw(yaw-math.pi/2)
@ -49,6 +59,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
le._damage = damage
le._is_critical = is_critical
le._startpos = pos
le._knockback = knockback
minetest.sound_play("mcl_bows_bow_shoot", {pos=pos, max_hear_distance=16}, true)
if shooter ~= nil and shooter:is_player() then
if obj:get_luaentity().player == "" then
@ -76,6 +87,7 @@ end
local player_shoot_arrow = function(itemstack, player, power, damage, is_critical)
local arrow_stack, arrow_stack_id = get_arrow(player)
local arrow_itemstring
local has_infinity_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "infinity")
if minetest.is_creative_enabled(player:get_player_name()) then
if arrow_stack then
@ -88,7 +100,9 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
return false
end
arrow_itemstring = arrow_stack:get_name()
arrow_stack:take_item()
if not has_infinity_enchantment then
arrow_stack:take_item()
end
local inv = player:get_inventory()
inv:set_stack("main", arrow_stack_id, arrow_stack)
end
@ -99,7 +113,7 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
local dir = player:get_look_dir()
local yaw = player:get_look_horizontal()
mcl_bows.shoot_arrow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical)
mcl_bows.shoot_arrow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item())
return true
end
@ -117,7 +131,7 @@ S("The speed and damage of the arrow increases the longer you charge. The regula
range = 4,
-- Trick to disable digging as well
on_use = function() return end,
groups = {weapon=1,weapon_ranged=1},
groups = {weapon=1,weapon_ranged=1,bow=1,enchantability=1},
})
-- Iterates through player inventory and resets all the bows in "charging" state back to their original stage
@ -128,6 +142,9 @@ local reset_bows = function(player)
if stack:get_name()=="mcl_bows:bow_0" or stack:get_name()=="mcl_bows:bow_1" or stack:get_name()=="mcl_bows:bow_2" then
stack:set_name("mcl_bows:bow")
list[place] = stack
elseif stack:get_name()=="mcl_bows:bow_0_enchanted" or stack:get_name()=="mcl_bows:bow_1_enchanted" or stack:get_name()=="mcl_bows:bow_2_enchanted" then
stack:set_name("mcl_bows:bow_enchanted")
list[place] = stack
end
end
inv:set_list("main", list)
@ -154,12 +171,16 @@ for level=0, 2 do
wield_scale = { x = 1.8, y = 1.8, z = 1 },
stack_max = 1,
range = 0, -- Pointing range to 0 to prevent punching with bow :D
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
groups = {not_in_creative_inventory=1, not_in_craft_guide=1, bow=1, enchantability=1},
-- Trick to disable digging as well
on_use = function() return end,
on_drop = function(itemstack, dropper, pos)
reset_bow_state(dropper)
itemstack:set_name("mcl_bows:bow")
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
itemstack:set_name("mcl_bows:bow_enchanted")
else
itemstack:set_name("mcl_bows:bow")
end
minetest.item_drop(itemstack, dropper, pos)
itemstack:take_item()
return itemstack
@ -176,9 +197,11 @@ controls.register_on_release(function(player, key, time)
if key~="RMB" then return end
local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
local wielditem = player:get_wielded_item()
if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2") then
if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or
wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then
local has_shot = false
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
local speed, damage
local p_load = bow_load[player:get_player_name()]
local charge
@ -218,9 +241,19 @@ controls.register_on_release(function(player, key, time)
has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical)
wielditem:set_name("mcl_bows:bow")
if enchanted then
wielditem:set_name("mcl_bows:bow_enchanted")
else
wielditem:set_name("mcl_bows:bow")
end
if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then
wielditem:add_wear(65535/BOW_DURABILITY)
local durability = BOW_DURABILITY
local unbreaking = mcl_enchanting.get_enchantment(wielditem, "unbreaking")
if unbreaking > 0 then
durability = durability * (unbreaking + 1)
end
wielditem:add_wear(65535/durability)
end
player:set_wielded_item(wielditem)
reset_bow_state(player, true)
@ -235,8 +268,13 @@ controls.register_on_hold(function(player, key, time)
end
local inv = minetest.get_inventory({type="player", name=name})
local wielditem = player:get_wielded_item()
if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or get_arrow(player)) then
wielditem:set_name("mcl_bows:bow_0")
if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and (creative or get_arrow(player)) then
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
if enchanted then
wielditem:set_name("mcl_bows:bow_0_enchanted")
else
wielditem:set_name("mcl_bows:bow_0")
end
player:set_wielded_item(wielditem)
if minetest.get_modpath("playerphysics") then
-- Slow player down when using bow
@ -249,12 +287,18 @@ controls.register_on_hold(function(player, key, time)
if type(bow_load[name]) == "number" then
if wielditem:get_name() == "mcl_bows:bow_0" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_HALF then
wielditem:set_name("mcl_bows:bow_1")
elseif wielditem:get_name() == "mcl_bows:bow_0_enchanted" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_HALF then
wielditem:set_name("mcl_bows:bow_1_enchanted")
elseif wielditem:get_name() == "mcl_bows:bow_1" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_FULL then
wielditem:set_name("mcl_bows:bow_2")
elseif wielditem:get_name() == "mcl_bows:bow_1_enchanted" and minetest.get_us_time() - bow_load[name] >= BOW_CHARGE_TIME_FULL then
wielditem:set_name("mcl_bows:bow_2_enchanted")
end
else
if wielditem:get_name() == "mcl_bows:bow_0" or wielditem:get_name() == "mcl_bows:bow_1" or wielditem:get_name() == "mcl_bows:bow_2" then
wielditem:set_name("mcl_bows:bow")
elseif wielditem:get_name() == "mcl_bows:bow_0_enchanted" or wielditem:get_name() == "mcl_bows:bow_1_enchanted" or wielditem:get_name() == "mcl_bows:bow_2_enchanted" then
wielditem:set_name("mcl_bows:bow_enchanted")
end
end
player:set_wielded_item(wielditem)
@ -270,7 +314,7 @@ minetest.register_globalstep(function(dtime)
local wielditem = player:get_wielded_item()
local wieldindex = player:get_wield_index()
local controls = player:get_player_control()
if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2") or wieldindex ~= bow_index[name]) then
if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2" and wielditem:get_name()~="mcl_bows:bow_0_enchanted" and wielditem:get_name()~="mcl_bows:bow_1_enchanted" and wielditem:get_name()~="mcl_bows:bow_2_enchanted") or wieldindex ~= bow_index[name]) then
reset_bow_state(player, true)
end
end
@ -305,7 +349,7 @@ end
minetest.register_craft({
type = "fuel",
recipe = "mcl_bows:bow",
recipe = "group:bow",
burntime = 15,
})

View File

@ -8,3 +8,4 @@ doc?
doc_identifier?
mesecons_button?
mcl_particles
mcl_enchanting

View File

@ -746,6 +746,7 @@ minetest.register_node("mcl_chests:ender_chest", {
end,
_mcl_blast_resistance = 3000,
_mcl_hardness = 22.5,
_mcl_silk_touch_drop = true,
on_rotate = simple_rotate,
})

View File

@ -2,3 +2,4 @@ mcl_core
mcl_worlds
mesecons
doc?
mcl_enchanting

View File

@ -56,8 +56,12 @@ minetest.register_globalstep(function(dtime)
for j,stack in ipairs(player:get_inventory():get_list("main")) do
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
local count = stack:get_count()
player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count))
local itemname = "mcl_compass:"..compass_image
if mcl_enchanting.is_enchanted(stack:get_name()) then
itemname = itemname .. "_enchanted"
end
stack:set_name(itemname)
player:get_inventory():set_stack("main", j, stack)
end
end
end
@ -94,7 +98,7 @@ for i,img in ipairs(images) do
inventory_image = img,
wield_image = img,
stack_max = 64,
groups = {not_in_creative_inventory=inv, compass=i, tool=1, disable_repair=1}
groups = {not_in_creative_inventory=inv, compass=i, tool=1, disable_repair=1, enchantability=1 }
})
-- Help aliases. Makes sure the lookup tool works correctly

View File

@ -10,6 +10,14 @@ else
ice_drawtype = "normal"
end
mcl_core.fortune_drop_ore = {
discrete_uniform_distribution = true,
min_count = 2,
max_count = 1,
get_chance = function (fortune_level) return 1 - 2 / (fortune_level + 2) end,
multiply = true,
}
minetest.register_node("mcl_core:stone", {
description = S("Stone"),
_doc_items_longdesc = S("One of the most common blocks in the world, almost the entire underground consists of stone. It sometimes contains ores. Stone may be created when water meets lava."),
@ -22,6 +30,7 @@ minetest.register_node("mcl_core:stone", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 1.5,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_core:stone_with_coal", {
@ -36,6 +45,8 @@ minetest.register_node("mcl_core:stone_with_coal", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = mcl_core.fortune_drop_ore,
})
minetest.register_node("mcl_core:stone_with_iron", {
@ -49,6 +60,7 @@ minetest.register_node("mcl_core:stone_with_iron", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
})
@ -63,6 +75,7 @@ minetest.register_node("mcl_core:stone_with_gold", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
})
local redstone_timer = 68.28
@ -95,6 +108,13 @@ minetest.register_node("mcl_core:stone_with_redstone", {
on_walk_over = redstone_ore_activate, -- Uses walkover mod
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mesecons:redstone"},
min_count = 4,
max_count = 5,
}
})
local redstone_ore_reactivate = function(pos)
@ -133,6 +153,13 @@ minetest.register_node("mcl_core:stone_with_redstone_lit", {
end,
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = {"mcl_core:stone_with_redstone"},
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mesecons:redstone"},
min_count = 4,
max_count = 5,
}
})
minetest.register_node("mcl_core:stone_with_lapis", {
@ -155,6 +182,7 @@ minetest.register_node("mcl_core:stone_with_lapis", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_fortune_drop = mcl_core.fortune_drop_ore,
})
minetest.register_node("mcl_core:stone_with_emerald", {
@ -168,6 +196,8 @@ minetest.register_node("mcl_core:stone_with_emerald", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = mcl_core.fortune_drop_ore,
})
minetest.register_node("mcl_core:stone_with_diamond", {
@ -181,6 +211,8 @@ minetest.register_node("mcl_core:stone_with_diamond", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = mcl_core.fortune_drop_ore,
})
minetest.register_node("mcl_core:stonebrick", {
@ -346,6 +378,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
_mcl_snowed = "mcl_core:dirt_with_grass_snow",
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.6,
_mcl_silk_touch_drop = true,
})
mcl_core.register_snowed_node("mcl_core:dirt_with_grass_snow", "mcl_core:dirt_with_grass", nil, nil, true)
@ -389,6 +422,7 @@ minetest.register_node("mcl_core:mycelium", {
_mcl_snowed = "mcl_core:mycelium_snow",
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.6,
_mcl_silk_touch_drop = true,
})
mcl_core.register_snowed_node("mcl_core:mycelium_snow", "mcl_core:mycelium")
@ -405,6 +439,7 @@ minetest.register_node("mcl_core:podzol", {
_mcl_snowed = "mcl_core:podzol_snow",
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.6,
_mcl_silk_touch_drop = true,
})
mcl_core.register_snowed_node("mcl_core:podzol_snow", "mcl_core:podzol")
@ -452,6 +487,24 @@ minetest.register_node("mcl_core:gravel", {
}),
_mcl_blast_resistance = 0.6,
_mcl_hardness = 0.6,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = {
[1] = {
max_items = 1,
items = {
{items = {'mcl_core:flint'},rarity = 7},
{items = {'mcl_core:gravel'}}
}
},
[2] = {
max_items = 1,
items = {
{items = {'mcl_core:flint'},rarity = 4},
{items = {'mcl_core:gravel'}}
}
},
[3] = "mcl_core:flint"
},
})
-- sandstone --
@ -594,6 +647,7 @@ minetest.register_node("mcl_core:clay", {
sounds = mcl_sounds.node_sound_dirt_defaults(),
_mcl_blast_resistance = 0.6,
_mcl_hardness = 0.6,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_core:brick_block", {
@ -776,6 +830,7 @@ minetest.register_node("mcl_core:ice", {
end,
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_core:packed_ice", {
@ -789,6 +844,7 @@ minetest.register_node("mcl_core:packed_ice", {
sounds = mcl_sounds.node_sound_glass_defaults(),
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
_mcl_silk_touch_drop = true,
})
-- Frosted Ice (4 nodes)
@ -972,6 +1028,7 @@ for i=1,8 do
drop = "mcl_throwing:snowball "..(i+1),
_mcl_blast_resistance = 0.1,
_mcl_hardness = 0.1,
_mcl_silk_touch_drop = true,
})
end
@ -989,6 +1046,7 @@ minetest.register_node("mcl_core:snowblock", {
drop = "mcl_throwing:snowball 4",
_mcl_blast_resistance = 0.2,
_mcl_hardness = 0.2,
_mcl_silk_touch_drop = true,
})
-- Add entry aliases for the Help

View File

@ -16,6 +16,7 @@ minetest.register_node("mcl_core:glass", {
drop = "",
_mcl_blast_resistance = 0.3,
_mcl_hardness = 0.3,
_mcl_silk_touch_drop = true,
})
------------------------
@ -51,6 +52,7 @@ function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color)
drop = "",
_mcl_blast_resistance = 0.3,
_mcl_hardness = 0.3,
_mcl_silk_touch_drop = true,
})
minetest.register_craft({

View File

@ -63,35 +63,39 @@ local register_wooden_planks = function(subname, description, tiles)
})
end
local register_leaves = function(subname, description, longdesc, tiles, drop1, drop1_rarity, drop2, drop2_rarity, leafdecay_distance)
local register_leaves = function(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance)
local drop
if leafdecay_distance == nil then
leafdecay_distance = 4
end
if drop2 then
drop = {
local apple_chances = {200, 180, 160, 120, 40}
local stick_chances = {50, 45, 30, 35, 10}
local function get_drops(fortune_level)
local drop = {
max_items = 1,
items = {
{
items = {drop1},
rarity = drop1_rarity,
items = {sapling},
rarity = sapling_chances[fortune_level + 1] or sapling_chances[fortune_level]
},
{
items = {drop2},
rarity = drop2_rarity,
items = {"mcl_core:stick 1"},
rarity = stick_chances[fortune_level + 1]
},
}
}
else
drop = {
max_items = 1,
items = {
{
items = {drop1},
rarity = drop1_rarity,
items = {"mcl_core:stick 2"},
rarity = stick_chances[fortune_level + 1]
},
}
}
}
if drop_apples then
table.insert(drop.items, {
items = {"mcl_core:apple"},
rarity = apple_chances[fortune_level + 1]
})
end
return drop
end
minetest.register_node("mcl_core:"..subname, {
@ -105,11 +109,13 @@ local register_leaves = function(subname, description, longdesc, tiles, drop1, d
paramtype = "light",
stack_max = 64,
groups = {handy=1,shearsy=1,swordy=1, leafdecay=leafdecay_distance, flammable=2, leaves=1, deco_block=1, dig_by_piston=1, fire_encouragement=30, fire_flammability=60},
drop = drop,
drop = get_drops(0),
_mcl_shears_drop = true,
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0.2,
_mcl_hardness = 0.2,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) },
})
end
@ -196,12 +202,13 @@ register_sapling("birchsapling", S("Birch Sapling"),
"mcl_core_sapling_birch.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16})
register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "mcl_core:sapling", 20, "mcl_core:apple", 200)
register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "mcl_core:darksapling", 20, "mcl_core:apple", 200)
register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "mcl_core:junglesapling", 40)
register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "mcl_core:acaciasapling", 20)
register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "mcl_core:sprucesapling", 20)
register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "mcl_core:birchsapling", 20)
register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "mcl_core:sapling", true, {20, 16, 12, 10})
register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "mcl_core:darksapling", true, {20, 16, 12, 10})
register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "mcl_core:junglesapling", false, {40, 26, 32, 24, 10})
register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "mcl_core:acaciasapling", false, {20, 16, 12, 10})
register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "mcl_core:sprucesapling", false, {20, 16, 12, 10})
register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "mcl_core:birchsapling", false, {20, 16, 12, 10})
-- Node aliases

View File

@ -70,7 +70,7 @@ minetest.register_tool("mcl_farming:hoe_wood", {
inventory_image = "farming_tool_woodhoe.png",
wield_scale = { x = 1.8, y = 1.8, z = 1 },
on_place = hoe_on_place_function(uses.wood),
groups = { tool=1, hoe=1 },
groups = { tool=1, hoe=1, enchantability=15 },
tool_capabilities = {
full_punch_interval = 1,
damage_groups = { fleshy = 1, },
@ -109,7 +109,7 @@ minetest.register_tool("mcl_farming:hoe_stone", {
inventory_image = "farming_tool_stonehoe.png",
wield_scale = { x = 1.8, y = 1.8, z = 1 },
on_place = hoe_on_place_function(uses.stone),
groups = { tool=1, hoe=1 },
groups = { tool=1, hoe=1, enchantability=5 },
tool_capabilities = {
full_punch_interval = 0.5,
damage_groups = { fleshy = 1, },
@ -143,7 +143,7 @@ minetest.register_tool("mcl_farming:hoe_iron", {
inventory_image = "farming_tool_steelhoe.png",
wield_scale = { x = 1.8, y = 1.8, z = 1 },
on_place = hoe_on_place_function(uses.iron),
groups = { tool=1, hoe=1 },
groups = { tool=1, hoe=1, enchantability=14 },
tool_capabilities = {
-- 1/3
full_punch_interval = 0.33333333,
@ -185,7 +185,7 @@ minetest.register_tool("mcl_farming:hoe_gold", {
inventory_image = "farming_tool_goldhoe.png",
wield_scale = { x = 1.8, y = 1.8, z = 1 },
on_place = hoe_on_place_function(uses.gold),
groups = { tool=1, hoe=1 },
groups = { tool=1, hoe=1, enchantability=22 },
tool_capabilities = {
full_punch_interval = 1,
damage_groups = { fleshy = 1, },
@ -228,7 +228,7 @@ minetest.register_tool("mcl_farming:hoe_diamond", {
inventory_image = "farming_tool_diamondhoe.png",
wield_scale = { x = 1.8, y = 1.8, z = 1 },
on_place = hoe_on_place_function(uses.diamond),
groups = { tool=1, hoe=1 },
groups = { tool=1, hoe=1, enchantability=10 },
tool_capabilities = {
full_punch_interval = 0.25,
damage_groups = { fleshy = 1, },

View File

@ -35,6 +35,14 @@ local melon_base_def = {
sounds = mcl_sounds.node_sound_wood_defaults(),
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mcl_farming:melon_item"},
min_count = 3,
max_count = 7,
cap = 9,
}
}
-- Drop proabilities for melon stem

View File

@ -112,6 +112,7 @@ pumpkin_face_base_def._doc_items_longdesc = S("A pumpkin can be worn as a helmet
pumpkin_face_base_def._doc_items_usagehelp = nil
pumpkin_face_base_def.tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"}
pumpkin_face_base_def.groups.armor_head=1
pumpkin_face_base_def.groups.enchantability=1
pumpkin_face_base_def._mcl_armor_mob_range_factor = 0
pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman"
pumpkin_face_base_def.groups.non_combat_armor=1

View File

@ -9,7 +9,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", {
inventory_image = "mcl_fire_flint_and_steel.png",
liquids_pointable = false,
stack_max = 1,
groups = { tool = 1 },
groups = { tool = 1, enchantability = 1 },
on_place = function(itemstack, user, pointed_thing)
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.under)

View File

@ -2,3 +2,4 @@ mcl_core
mcl_sounds
mcl_loot
mcl_mobs
mcl_enchanting

View File

@ -18,8 +18,8 @@ local bobber_ENTITY={
_lastpos={},
_dive = false,
_waittick = nil,
_tick = 0,
_waittime = nil,
_time = 0,
player=nil,
_oldy = nil,
objtype="fishing",
@ -33,15 +33,19 @@ local fish = function(itemstack, player)
local ent = nil
local noent = true
local durability = 65
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
if unbreaking > 0 then
durability = durability * (unbreaking + 1)
end
--Check for bobber if so handle.
for n = 1, #objs do
ent = objs[n]:get_luaentity()
if ent then
if ent.player and ent.objtype=="fishing" then
if (player:get_player_name() == ent.player) then
if mcl_experience.throw_experience then
mcl_experience.throw_experience(pos, math.random(1,6))
end
noent = false
if ent._dive == true then
local itemname
@ -104,10 +108,13 @@ local fish = function(itemstack, player)
if inv:room_for_item("main", item) then
inv:add_item("main", item)
end
if mcl_experience.throw_experience then
mcl_experience.throw_experience(pos, math.random(1,6))
end
if not minetest.is_creative_enabled(player:get_player_name()) then
local idef = itemstack:get_definition()
itemstack:add_wear(65535/65) -- 65 uses
itemstack:add_wear(65535/durability) -- 65 uses
if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then
minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true)
end
@ -121,7 +128,7 @@ local fish = function(itemstack, player)
if def.walkable then
if not minetest.is_creative_enabled(player:get_player_name()) then
local idef = itemstack:get_definition()
itemstack:add_wear((65535/65)*2) -- if so and not creative then wear double like in MC.
itemstack:add_wear((65535/durability)*2) -- if so and not creative then wear double like in MC.
if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then
minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true)
end
@ -172,12 +179,11 @@ local bobber_on_step = function(self, dtime)
self.object:remove()
return
end
local wield = player:get_wielded_item()
--Check if player is nearby
if self._tick % 5 == 0 and self.player ~= nil and player ~= nil then
if self.player ~= nil and player ~= nil then
--Destroy bobber if item not wielded.
local wield = player:get_wielded_item()
if ((not wield) or (wield:get_name() ~= "mcl_fishing:fishing_rod")) then
if ((not wield) or (minetest.get_item_group(wield:get_name(), "fishing_rod") <= 0)) then
self.object:remove()
return
end
@ -225,33 +231,34 @@ local bobber_on_step = function(self, dtime)
pos = {x=epos["x"]+math.random(-1,1)*math.random()/2,y=epos["y"]+0.1,z=epos["z"]+math.random(-1,1)*math.random()/2},
velocity = {x=0, y=4, z=0},
acceleration = {x=0, y=-5, z=0},
expirationtime = math.random(),
size = math.random()+0.5,
expirationtime = math.random() * 0.5,
size = math.random(),
collisiondetection = true,
vertical = false,
texture = "mcl_particles_bubble.png",
})
end
if self._tick ~= self._waittick then
self._tick = self._tick + 1
if self._time < self._waittime then
self._time = self._time + dtime
else
self._waittick = nil
self._tick = 0
self._waittime = 0
self._time = 0
self._dive = false
end
else if self._waittick == nil then
else if not self._waittime or self._waittime <= 0 then
-- wait for random number of ticks.
self._waittick = math.random(50,333)
local lure_enchantment = wield and mcl_enchanting.get_enchantment(wield, "lure") or 0
self._waittime = math.random(5, 30) - lure_enchantment * 5
else
if self._tick ~= self._waittick then
self._tick = self._tick + 1
if self._time < self._waittime then
self._time = self._time + dtime
else
--wait time is over time to dive.
-- wait time is over time to dive.
self._dive = true
self.object:set_velocity({x=0,y=-2,z=0})
self.object:set_acceleration({x=0,y=5,z=0})
self._waittick = 30
self._tick = 0
self._waittime = 0.8
self._time = 0
end
end
end
@ -315,7 +322,7 @@ minetest.register_tool("mcl_fishing:fishing_rod", {
_tt_help = S("Catches fish in water"),
_doc_items_longdesc = S("Fishing rods can be used to catch fish."),
_doc_items_usagehelp = S("Rightclick to launch the bobber. When it sinks right-click again to reel in an item. Who knows what you're going to catch?"),
groups = { tool=1 },
groups = { tool=1, fishing_rod=1, enchantability=1 },
inventory_image = "mcl_fishing_fishing_rod.png",
wield_image = "mcl_fishing_fishing_rod.png^[transformR270",
wield_scale = { x = 1.5, y = 1.5, z = 1 },
@ -343,7 +350,7 @@ minetest.register_craft({
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_fishing:fishing_rod",
recipe = "group:fishing_rod",
burntime = 15,
})

View File

@ -98,6 +98,16 @@ local wheat_seed_drop = {
}
}
local fortune_wheat_seed_drop = {
discrete_uniform_distribution = true,
items = {"mcl_farming:wheat_seeds"},
chance = 1 / 8,
min_count = 1,
max_count = 1,
factor = 2,
overwrite = true,
}
-- CHECKME: How does tall grass behave when pushed by a piston?
--- Tall Grass ---
@ -126,6 +136,7 @@ local def_tallgrass = {
sounds = mcl_sounds.node_sound_leaves_defaults(),
drop = wheat_seed_drop,
_mcl_shears_drop = true,
_mcl_fortune_drop = fortune_wheat_seed_drop,
node_placement_prediction = "",
on_place = on_place_flower,
_mcl_blast_resistance = 0,
@ -148,7 +159,7 @@ def_fern.selection_box = {
minetest.register_node("mcl_flowers:fern", def_fern)
local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_img, selbox_radius, selbox_top_height, drop, shears_drop, is_flower, grass_color)
local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_img, selbox_radius, selbox_top_height, drop, shears_drop, is_flower, grass_color, fortune_drop)
if not inv_img then
inv_img = top_img
end
@ -200,6 +211,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
buildable_to = true,
drop = drop_bottom,
_mcl_shears_drop = shears_drop,
_mcl_fortune_drop = fortune_drop,
node_placement_prediction = "",
selection_box = {
type = "fixed",
@ -305,6 +317,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
},
drop = drop_top,
_mcl_shears_drop = shears_drop,
_mcl_fortune_drop = fortune_drop,
after_destruct = function(pos, oldnode)
-- Remove bottom half of flower (if it exists)
local top = pos
@ -334,8 +347,8 @@ add_large_plant("sunflower", S("Sunflower"), S("A sunflower is a large plant whi
local longdesc_grass = S("Double tallgrass a variant of tall grass and occupies two blocks. It can be harvested for wheat seeds.")
local longdesc_fern = S("Large fern is a variant of fern and occupies two blocks. It can be harvested for wheat seeds.")
add_large_plant("double_grass", S("Double Tallgrass"), longdesc_grass, "mcl_flowers_double_plant_grass_bottom.png", "mcl_flowers_double_plant_grass_top.png", "mcl_flowers_double_plant_grass_inv.png", 6/16, 4/16, wheat_seed_drop, {"mcl_flowers:tallgrass 2"}, false, true)
add_large_plant("double_fern", S("Large Fern"), longdesc_fern, "mcl_flowers_double_plant_fern_bottom.png", "mcl_flowers_double_plant_fern_top.png", "mcl_flowers_double_plant_fern_inv.png", 5/16, 5/16, wheat_seed_drop, {"mcl_flowers:fern 2"}, false, true)
add_large_plant("double_grass", S("Double Tallgrass"), longdesc_grass, "mcl_flowers_double_plant_grass_bottom.png", "mcl_flowers_double_plant_grass_top.png", "mcl_flowers_double_plant_grass_inv.png", 6/16, 4/16, wheat_seed_drop, {"mcl_flowers:tallgrass 2"}, false, true, nil, fortune_wheat_seed_drop)
add_large_plant("double_fern", S("Large Fern"), longdesc_fern, "mcl_flowers_double_plant_fern_bottom.png", "mcl_flowers_double_plant_fern_top.png", "mcl_flowers_double_plant_fern_inv.png", 5/16, 5/16, wheat_seed_drop, {"mcl_flowers:fern 2"}, false, true, nil, fortune_wheat_seed_drop)
minetest.register_abm({
label = "Pop out flowers",

View File

@ -42,7 +42,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor)
{ -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
},
},
groups = {handy=1, armor_head=1,non_combat_armor=1, head=1, deco_block=1, dig_by_piston=1},
groups = {handy=1, armor_head=1,non_combat_armor=1, head=1, deco_block=1, dig_by_piston=1, enchantability=1},
-- The head textures are based off the textures of an actual mob.
tiles = {
-- Note: bottom texture is overlaid over top texture to get rid of possible transparency.

View File

@ -6,6 +6,7 @@ local template = {
is_ground_content = true,
_mcl_blast_resistance = 0.2,
_mcl_hardness = 0.2,
_mcl_silk_touch_drop = true,
}
local red = table.copy(template)

View File

@ -27,6 +27,14 @@ minetest.register_node("mcl_nether:glowstone", {
sounds = mcl_sounds.node_sound_glass_defaults(),
_mcl_blast_resistance = 0.3,
_mcl_hardness = 0.3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mcl_nether:glowstone_dust"},
min_count = 2,
max_count = 4,
cap = 4,
}
})
minetest.register_node("mcl_nether:quartz_ore", {
@ -40,6 +48,8 @@ minetest.register_node("mcl_nether:quartz_ore", {
sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = mcl_core.fortune_drop_ore
})
-- For eternal fire on top of netherrack and magma blocks

View File

@ -93,6 +93,12 @@ minetest.register_node("mcl_nether:nether_wart", {
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mcl_nether:nether_wart_item"},
min_count = 2,
max_count = 4,
}
})
minetest.register_craftitem("mcl_nether:nether_wart_item", {

View File

@ -91,6 +91,7 @@ for c=1, #corals do
drop = "mcl_ocean:dead_"..id.."_coral_block",
_mcl_hardness = 1.5,
_mcl_blast_resistance = 6,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_ocean:dead_"..id.."_coral_block", {
description = corals[c][3],
@ -135,6 +136,7 @@ for c=1, #corals do
end,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_ocean:dead_"..id.."_coral", {
description = corals[c][5],
@ -202,6 +204,7 @@ for c=1, #corals do
end,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_mcl_silk_touch_drop = true,
})
minetest.register_node("mcl_ocean:dead_"..id.."_coral_fan", {
description = corals[c][7],
@ -234,6 +237,7 @@ for c=1, #corals do
end,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_mcl_silk_touch_drop = true,
})
if mod_doc then

View File

@ -21,6 +21,14 @@ minetest.register_node("mcl_ocean:sea_lantern", {
sounds = mcl_sounds.node_sound_glass_defaults(),
_mcl_blast_resistance = 0.3,
_mcl_hardness = 0.3,
_mcl_silk_touch_drop = true,
_mcl_fortune_drop = {
discrete_uniform_distribution = true,
items = {"mcl_ocean:prismarine_crystals"},
min_count = 2,
max_count = 3,
cap = 5,
}
})
minetest.register_node("mcl_ocean:prismarine", {

View File

@ -81,7 +81,7 @@ minetest.register_tool("mcl_tools:pick_wood", {
_doc_items_hidden = false,
inventory_image = "default_tool_woodpick.png",
wield_scale = wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=2, },
groups = { tool=1, pickaxe=1, dig_speed_class=2, enchantability=15 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
@ -100,7 +100,7 @@ minetest.register_tool("mcl_tools:pick_stone", {
_doc_items_longdesc = pickaxe_longdesc,
inventory_image = "default_tool_stonepick.png",
wield_scale = wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=3, },
groups = { tool=1, pickaxe=1, dig_speed_class=3, enchantability=5 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
@ -119,7 +119,7 @@ minetest.register_tool("mcl_tools:pick_iron", {
_doc_items_longdesc = pickaxe_longdesc,
inventory_image = "default_tool_steelpick.png",
wield_scale = wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=4, },
groups = { tool=1, pickaxe=1, dig_speed_class=4, enchantability=14 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
@ -138,7 +138,7 @@ minetest.register_tool("mcl_tools:pick_gold", {
_doc_items_longdesc = pickaxe_longdesc,
inventory_image = "default_tool_goldpick.png",
wield_scale = wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=6, },
groups = { tool=1, pickaxe=1, dig_speed_class=6, enchantability=22 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
@ -157,7 +157,7 @@ minetest.register_tool("mcl_tools:pick_diamond", {
_doc_items_longdesc = pickaxe_longdesc,
inventory_image = "default_tool_diamondpick.png",
wield_scale = wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=5, },
groups = { tool=1, pickaxe=1, dig_speed_class=5, enchantability=10 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
@ -277,7 +277,7 @@ minetest.register_tool("mcl_tools:shovel_wood", {
inventory_image = "default_tool_woodshovel.png",
wield_image = "default_tool_woodshovel.png^[transformR90",
wield_scale = wield_scale,
groups = { tool=1, shovel=1, dig_speed_class=2, },
groups = { tool=1, shovel=1, dig_speed_class=2, enchantability=15 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=1,
@ -298,7 +298,7 @@ minetest.register_tool("mcl_tools:shovel_stone", {
inventory_image = "default_tool_stoneshovel.png",
wield_image = "default_tool_stoneshovel.png^[transformR90",
wield_scale = wield_scale,
groups = { tool=1, shovel=1, dig_speed_class=3, },
groups = { tool=1, shovel=1, dig_speed_class=3, enchantability=5 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=3,
@ -319,7 +319,7 @@ minetest.register_tool("mcl_tools:shovel_iron", {
inventory_image = "default_tool_steelshovel.png",
wield_image = "default_tool_steelshovel.png^[transformR90",
wield_scale = wield_scale,
groups = { tool=1, shovel=1, dig_speed_class=4, },
groups = { tool=1, shovel=1, dig_speed_class=4, enchantability=14 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=4,
@ -361,7 +361,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
inventory_image = "default_tool_diamondshovel.png",
wield_image = "default_tool_diamondshovel.png^[transformR90",
wield_scale = wield_scale,
groups = { tool=1, shovel=1, dig_speed_class=5, },
groups = { tool=1, shovel=1, dig_speed_class=5, enchantability=10 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=5,
@ -383,7 +383,7 @@ minetest.register_tool("mcl_tools:axe_wood", {
_doc_items_hidden = false,
inventory_image = "default_tool_woodaxe.png",
wield_scale = wield_scale,
groups = { tool=1, axe=1, dig_speed_class=2, },
groups = { tool=1, axe=1, dig_speed_class=2, enchantability=15 },
tool_capabilities = {
full_punch_interval = 1.25,
max_drop_level=1,
@ -401,7 +401,7 @@ minetest.register_tool("mcl_tools:axe_stone", {
_doc_items_longdesc = axe_longdesc,
inventory_image = "default_tool_stoneaxe.png",
wield_scale = wield_scale,
groups = { tool=1, axe=1, dig_speed_class=3, },
groups = { tool=1, axe=1, dig_speed_class=3, enchantability=5 },
tool_capabilities = {
full_punch_interval = 1.25,
max_drop_level=3,
@ -419,7 +419,7 @@ minetest.register_tool("mcl_tools:axe_iron", {
_doc_items_longdesc = axe_longdesc,
inventory_image = "default_tool_steelaxe.png",
wield_scale = wield_scale,
groups = { tool=1, axe=1, dig_speed_class=4, },
groups = { tool=1, axe=1, dig_speed_class=4, enchantability=14 },
tool_capabilities = {
-- 1/0.9
full_punch_interval = 1.11111111,
@ -438,7 +438,7 @@ minetest.register_tool("mcl_tools:axe_gold", {
_doc_items_longdesc = axe_longdesc,
inventory_image = "default_tool_goldaxe.png",
wield_scale = wield_scale,
groups = { tool=1, axe=1, dig_speed_class=6, },
groups = { tool=1, axe=1, dig_speed_class=6, enchantability=22 },
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=2,
@ -456,7 +456,7 @@ minetest.register_tool("mcl_tools:axe_diamond", {
_doc_items_longdesc = axe_longdesc,
inventory_image = "default_tool_diamondaxe.png",
wield_scale = wield_scale,
groups = { tool=1, axe=1, dig_speed_class=5, },
groups = { tool=1, axe=1, dig_speed_class=5, enchantability=10 },
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=5,
@ -477,7 +477,7 @@ minetest.register_tool("mcl_tools:sword_wood", {
_doc_items_hidden = false,
inventory_image = "default_tool_woodsword.png",
wield_scale = wield_scale,
groups = { weapon=1, sword=1, dig_speed_class=2, },
groups = { weapon=1, sword=1, dig_speed_class=2, enchantability=15 },
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=1,
@ -496,7 +496,7 @@ minetest.register_tool("mcl_tools:sword_stone", {
_doc_items_longdesc = sword_longdesc,
inventory_image = "default_tool_stonesword.png",
wield_scale = wield_scale,
groups = { weapon=1, sword=1, dig_speed_class=3, },
groups = { weapon=1, sword=1, dig_speed_class=3, enchantability=5 },
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=3,
@ -515,7 +515,7 @@ minetest.register_tool("mcl_tools:sword_iron", {
_doc_items_longdesc = sword_longdesc,
inventory_image = "default_tool_steelsword.png",
wield_scale = wield_scale,
groups = { weapon=1, sword=1, dig_speed_class=4, },
groups = { weapon=1, sword=1, dig_speed_class=4, enchantability=14 },
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=4,
@ -534,7 +534,7 @@ minetest.register_tool("mcl_tools:sword_gold", {
_doc_items_longdesc = sword_longdesc,
inventory_image = "default_tool_goldsword.png",
wield_scale = wield_scale,
groups = { weapon=1, sword=1, dig_speed_class=6, },
groups = { weapon=1, sword=1, dig_speed_class=6, enchantability=22 },
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=2,
@ -553,7 +553,7 @@ minetest.register_tool("mcl_tools:sword_diamond", {
_doc_items_longdesc = sword_longdesc,
inventory_image = "default_tool_diamondsword.png",
wield_scale = wield_scale,
groups = { weapon=1, sword=1, dig_speed_class=5, },
groups = { weapon=1, sword=1, dig_speed_class=5, enchantability=10 },
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=5,
@ -576,7 +576,7 @@ minetest.register_tool("mcl_tools:shears", {
inventory_image = "default_tool_shears.png",
wield_image = "default_tool_shears.png",
stack_max = 1,
groups = { tool=1, shears=1, dig_speed_class=4, },
groups = { tool=1, shears=1, dig_speed_class=4, enchantability=1 },
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level=1,

View File

@ -176,7 +176,7 @@ minetest.register_tool("screwdriver:screwdriver", {
description = S("Screwdriver"),
inventory_image = "screwdriver.png",
wield_image = "screwdriver.png^[transformFX",
groups = { tool = 1, not_in_creative_inventory = 1 },
groups = { tool = 1, not_in_creative_inventory = 1, enchantability = 1 },
on_use = function(itemstack, user, pointed_thing)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 200)
return itemstack

View File

@ -127,6 +127,7 @@ function xpanes.register_pane(name, def)
connect_sides = { "left", "right" },
_mcl_blast_resistance = def._mcl_blast_resistance,
_mcl_hardness = def._mcl_hardness,
_mcl_silk_touch_drop = def._mcl_silk_touch_drop,
})
local groups = table.copy(def.groups)
@ -155,6 +156,7 @@ function xpanes.register_pane(name, def)
drop = drop,
_mcl_blast_resistance = def._mcl_blast_resistance,
_mcl_hardness = def._mcl_hardness,
_mcl_silk_touch_drop = def._mcl_silk_touch_drop,
})
minetest.register_craft({
@ -204,6 +206,7 @@ local pane = function(description, node, append)
drop = "",
_mcl_blast_resistance = 0.3,
_mcl_hardness = 0.3,
_mcl_silk_touch_drop = true,
})
if mod_doc and not is_canonical then

View File

@ -1 +1,2 @@
mcl_armor
mcl_enchanting

Some files were not shown because too many files have changed in this diff Show More