Compare commits

...

33 Commits

Author SHA1 Message Date
Nils Dagsson Moskopp 9541e401de
Fix handheld maps not displaying in Minetest 5.5.0
The function dynamic_add_media() was changed in incompatible ways in
several minor versions of Minetest, breaking the display of handheld
maps in Minetest 5.5.0. This patch makes handheld maps display there.

The function was blocking with one argument in Minetest 5.3. It was also
blocking in Minetest 5.4, but took an additional argument for a function
to execute once the media had been received. Calling dynamic_add_media()
with a single argument had been deprecated; a function that did nothing
was provided in mcl_maps to satisfy the changed argument requirements.

In Minetest 5.5, dynamic_add_media() was changed to non-blocking. This
introduced a race condition in mcl_maps, where a client often tried to
display a map before it had received the map texture from the server.

Opening an issue on the Minetest issue tracker led to it being closed in
about 20 minutes: <https://github.com/minetest/minetest/issues/11997>
2022-02-25 23:11:34 +01:00
Nils Dagsson Moskopp 19831bbe0d
Use raw packets in RLE compression in tga_encoder 2022-02-20 10:15:06 +01:00
Nils Dagsson Moskopp f2e6e61c47
Darken handheld map in low light conditions 2022-02-20 10:12:47 +01:00
Nils Dagsson Moskopp b10214e1e0
Change map ids to timestamp with random suffix
Before this patch, mcl_maps used mod storage to store a map id counter.
This made it possible to set map ids sequentially. However, mod storage
is not included in world downloads – which means that a world based on a
world download would start counting at zero and overwrite existing maps.

This patch changes map ids to be a combination of the Unix timestamp and
a random value. This makes it possible to have almost sequential map ids
without the need to store a map id counter.
2022-02-20 10:12:46 +01:00
Nils Dagsson Moskopp 738cbf4861
Add setting for update frequency of handheld maps 2022-02-20 10:12:46 +01:00
Nils Dagsson Moskopp e91f29ac24
Show a message on how to add markers to maps 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp 6ff0303802
Add markers to maps (using banners) 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp f0a925aa20
Display location of item frame in item frame map 2022-02-20 10:12:45 +01:00
Nils Dagsson Moskopp 16a68af119
Store mcl_maps textures in map item meta
Map textures are stored as files in a world directory and in item meta.
For a typical forest landscape, this adds up to 10kb to map item meta.

The main purpose of this is to allow maps to work in world downloads:
Maps are automatically restored when no textures are found on disk.

As a side effect, players will probably lag a bit if they fill their
inventory with many (shulkers full of) maps, but enchanted items or
books can be used for the same purpose already, so this is not new.

Saving PNGs can lead to a few kb of savings here, but would hinder
enhancements to mcl_maps that are based on updating the stored map,
as reading and writing TGA images is stupidly easy compared to PNG.
(Really, any bitmap format is about the same size zlib compressed.)

Note that any hypothetical future version of mcl_maps that changes the
storage format (e.g. to compressed PNM) or sends PNG maps to clients has
to include a TGA parser, to avoid breaking existing maps in user worlds.
2022-02-20 10:12:44 +01:00
Nils Dagsson Moskopp 82a5708144
Display large player dot on maps for nearby player 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp e24a38d864
Increase contrast of player marker on maps 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp 62ee1267de
Add diagonal player marker to maps 2022-02-20 10:12:43 +01:00
Nils Dagsson Moskopp 9566ea58e3
Fix TGA file writing on Windows
Before this patch, the tga_encoder mod would write corrupted TGA files
on Windows: Bytes that looked like newlines were replaced by a carriage
return and a newline.
2022-02-20 10:12:42 +01:00
Nils Dagsson Moskopp c6436d7176
Reduce TGA filesize by 25% by using 16-bit colors 2022-02-20 10:12:41 +01:00
Nils Dagsson Moskopp ff249500a6
Speed up TGA encoding by creating fewer strings 2022-02-20 10:12:41 +01:00
Nils Dagsson Moskopp e20e264d8c
Use RLE compression in tga_encoder 2022-02-20 10:12:40 +01:00
Lizzy Fleckenstein 2110fccd9d
Add updated tga_encoder 2022-02-20 10:12:40 +01:00
AFCMS c5a5eaa96e
Update French translation of mcl_maps 2022-02-20 10:12:39 +01:00
Marcin Serwin ad2ce5c719
Update polish translation of mcl_maps 2022-02-20 10:12:39 +01:00
Marcin Serwin 5ef4a81683
Add polish translation of mcl_maps 2022-02-20 10:12:38 +01:00
AFCMS 8015cbc10c
Localize functions in mcl_maps 2022-02-20 10:12:38 +01:00
Lizzy Fleckenstein b6540c0d80
Add moving marker for the player 2022-02-20 10:12:37 +01:00
Lizzy Fleckenstein ea272c40a0
Add craft predict for map copying 2022-02-20 10:12:37 +01:00
Lizzy Fleckenstein ec23f89033
Fix tt snippet to update wield filled maps as well 2022-02-20 10:12:36 +01:00
Lizzy Fleckenstein 9e4d630987
Prevent placing of wielded maps 2022-02-20 10:12:35 +01:00
Lizzy Fleckenstein 8f077ff55b
Copy stack before accessing it in add_item 2022-02-20 10:12:35 +01:00
Lizzy Fleckenstein 697a37c266
Make it look like the player is holding the map in their hand 2022-02-20 10:12:34 +01:00
Lizzy Fleckenstein f3f2560b32
Make maps show their image when in itemframes 2022-02-20 10:12:34 +01:00
Lizzy Fleckenstein ad6ebad06f
Show empty map in creative inv, but don't show filled map there 2022-02-20 10:12:33 +01:00
Lizzy Fleckenstein d0b78d38f5
Implement copying maps 2022-02-20 10:12:33 +01:00
Lizzy Fleckenstein 8bee9270ef
Stack filled maps that have the same metadata 2022-02-20 10:12:33 +01:00
Lizzy Fleckenstein 7914ce72e4
Add API to create filled map 2022-02-20 10:12:32 +01:00
Lizzy Fleckenstein 1478b7ebea
Add Real Maps 2022-02-20 10:12:27 +01:00
33 changed files with 1660 additions and 141 deletions

View File

@ -405,3 +405,18 @@ function mcl_util.get_object_center(obj)
pos.y = pos.y + (ymax - ymin) / 2.0
return pos
end
function mcl_util.call_on_rightclick(itemstack, player, pointed_thing)
-- Call on_rightclick if the pointed node defines it
if pointed_thing and pointed_thing.type == "node" then
local pos = pointed_thing.under
local node = minetest.get_node(pos)
if player and not player:get_player_control().sneak then
local nodedef = minetest.registered_nodes[node.name]
local on_rightclick = nodedef and nodedef.on_rightclick
if on_rightclick then
return on_rightclick(pos, node, player, itemstack, pointed_thing) or itemstack
end
end
end
end

View File

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

View File

@ -0,0 +1,4 @@
# tga_encoder
A TGA Encoder written in Lua without the use of external Libraries.
May be used as a Minetest mod.

View File

@ -0,0 +1,158 @@
tga_encoder = {}
local image = setmetatable({}, {
__call = function(self, ...)
local t = setmetatable({}, {__index = self})
t:constructor(...)
return t
end,
})
function image:constructor(pixels)
self.data = ""
self.pixels = pixels
self.width = #pixels[1]
self.height = #pixels
self:encode()
end
function image:encode_colormap_spec()
self.data = self.data
.. string.char(0, 0) -- first entry index
.. string.char(0, 0) -- number of entries
.. string.char(0) -- bits per pixel
end
function image:encode_image_spec()
self.data = self.data
.. string.char(0, 0) -- X-origin
.. string.char(0, 0) -- Y-origin
.. string.char(self.width % 256, math.floor(self.width / 256)) -- width
.. string.char(self.height % 256, math.floor(self.height / 256)) -- height
.. string.char(16) -- pixel depth (ARRRRRGGGGGBBBBB = 2 bytes = 16 bits)
.. string.char(0) -- image descriptor
end
function image:encode_header()
self.data = self.data
.. string.char(0) -- image id
.. string.char(0) -- color map type
.. string.char(10) -- image type (RLE RGB = 10)
self:encode_colormap_spec() -- color map specification
self:encode_image_spec() -- image specification
end
function image:encode_data()
local colorword = nil
local previous_r = nil
local previous_g = nil
local previous_b = nil
local raw_pixel = ''
local raw_pixels = {}
local count = 1
local packets = {}
local raw_packet = ''
local rle_packet = ''
-- Sample depth rescaling is done according to the algorithm presented in:
-- <https://www.w3.org/TR/2003/REC-PNG-20031110/#13Sample-depth-rescaling>
local max_sample_in = math.pow(2, 8) - 1
local max_sample_out = math.pow(2, 5) - 1
for _, row in ipairs(self.pixels) do
for _, pixel in ipairs(row) do
if pixel[1] ~= previous_r or pixel[2] ~= previous_g or pixel[3] ~= previous_b or count == 128 then
if nil ~= previous_r then
colorword = 32768 +
((math.floor((previous_r * max_sample_out / max_sample_in) + 0.5)) * 1024) +
((math.floor((previous_g * max_sample_out / max_sample_in) + 0.5)) * 32) +
((math.floor((previous_b * max_sample_out / max_sample_in) + 0.5)) * 1)
if 1 == count then
-- remember pixel verbatim for raw encoding
raw_pixel = string.char(colorword % 256, math.floor(colorword / 256))
raw_pixels[#raw_pixels + 1] = raw_pixel
if 128 == #raw_pixels then
raw_packet = string.char(#raw_pixels - 1)
packets[#packets + 1] = raw_packet
for i=1, #raw_pixels do
packets[#packets +1] = raw_pixels[i]
end
raw_pixels = {}
end
else
-- encode raw pixels, if any
if #raw_pixels > 0 then
raw_packet = string.char(#raw_pixels - 1)
packets[#packets + 1] = raw_packet
for i=1, #raw_pixels do
packets[#packets +1] = raw_pixels[i]
end
raw_pixels = {}
end
-- RLE encoding
rle_packet = string.char(128 + count - 1, colorword % 256, math.floor(colorword / 256))
packets[#packets +1] = rle_packet
end
end
count = 1
previous_r = pixel[1]
previous_g = pixel[2]
previous_b = pixel[3]
else
count = count + 1
end
end
end
colorword = 32768 +
((math.floor((previous_r * max_sample_out / max_sample_in) + 0.5)) * 1024) +
((math.floor((previous_g * max_sample_out / max_sample_in) + 0.5)) * 32) +
((math.floor((previous_b * max_sample_out / max_sample_in) + 0.5)) * 1)
if 1 == count then
raw_pixel = string.char(colorword % 256, math.floor(colorword / 256))
raw_pixels[#raw_pixels + 1] = raw_pixel
raw_packet = string.char(#raw_pixels - 1)
packets[#packets + 1] = raw_packet
for i=1, #raw_pixels do
packets[#packets +1] = raw_pixels[i]
end
raw_pixels = {}
else
-- encode raw pixels, if any
if #raw_pixels > 0 then
raw_packet = string.char(#raw_pixels - 1)
packets[#packets + 1] = raw_packet
for i=1, #raw_pixels do
packets[#packets +1] = raw_pixels[i]
end
raw_pixels = {}
end
-- RLE encoding
rle_packet = string.char(128 + count - 1, colorword % 256, math.floor(colorword / 256))
packets[#packets +1] = rle_packet
end
self.data = self.data .. table.concat(packets)
end
function image:encode_footer()
self.data = self.data
.. string.char(0, 0, 0, 0) -- extension area offset
.. string.char(0, 0, 0, 0) -- developer area offset
.. "TRUEVISION-XFILE"
.. "."
.. string.char(0)
end
function image:encode()
self:encode_header() -- header
-- no color map and image id data
self:encode_data() -- encode data
-- no extension or developer area
self:encode_footer() -- footer
end
function image:save(filename)
local f = assert(io.open(filename, "wb"))
f:write(self.data)
f:close()
end
tga_encoder.image = image

View File

@ -0,0 +1,3 @@
name = tga_encoder
author = Fleckenstein
description = A TGA Encoder written in Lua without the use of external Libraries.

View File

@ -195,7 +195,7 @@ local professions = {
{
-- TODO: replace with empty map
{ { "mcl_core:emerald", 7, 11}, { "mcl_maps:filled_map", 1, 1 } },
{ { "mcl_core:emerald", 7, 11}, { "mcl_maps:empty_map", 1, 1 } },
},
-- TODO: special maps

View File

@ -10,6 +10,10 @@ tt.register_snippet = function(func)
table.insert(tt.registered_snippets, func)
end
tt.register_priority_snippet = function(func)
table.insert(tt.registered_snippets, 1, func)
end
dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets.lua")
-- Apply item description updates
@ -21,8 +25,6 @@ local function apply_snippets(desc, itemstring, toolcaps, itemstack)
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

View File

@ -343,6 +343,18 @@ minetest.register_node("mcl_banners:hanging_banner", {
end,
})
function mcl_banners.get_banner_colorid(pos)
local node_meta = minetest.get_meta(pos)
local banner_item = node_meta:get_inventory():get_stack("banner", 1)
local banner_item_name = banner_item:get_name()
local colorid = colors_reverse[banner_item_name]
return colorid
end
function mcl_banners.colorid_to_hexcolor(colorid)
return mcl_banners.colors[colorid][4]
end
-- for pattern_name, pattern in pairs(patterns) do
for colorid, colortab in pairs(mcl_banners.colors) do
for i, pattern_name in ipairs(pattern_names) do

View File

@ -361,4 +361,4 @@ minetest.register_on_joinplayer(mcl_enchanting.initialize_player)
minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields)
minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action)
minetest.register_on_player_inventory_action(mcl_enchanting.on_inventory_action)
table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet)
tt.register_priority_snippet(mcl_enchanting.enchantments_snippet)

View File

@ -53,6 +53,77 @@ minetest.register_entity("mcl_itemframes:item",{
end,
})
minetest.register_entity("mcl_itemframes:map", {
initial_properties = {
visual = "upright_sprite",
visual_size = {x = 1, y = 1},
pointable = false,
physical = false,
collide_with_objects = false,
textures = {"blank.png"},
},
on_activate = function(self, staticdata)
local data = minetest.deserialize(staticdata)
-- originally this function only got the id
if nil == data then
self.id = data
self._pos = { x = 0/0, y = 0/0, z = 0/0 }
self._minp = { x = 0/0, y = 0/0, z = 0/0 }
self._maxp = { x = 0/0, y = 0/0, z = 0/0 }
self._banners = {}
else
self.id = data.id
self._pos = data._pos
self._minp = data._minp
self._maxp = data._maxp
self._banners = data._banners
end
local texture = mcl_maps.load_map(self.id)
if nil ~= self._banners and #self._banners > 0 then
local border = { top = 0, left = 0, bottom = 0, right = 0 }
local banner_overlay = mcl_maps.make_banner_overlay(
self._banners,
self._minp,
self._maxp,
border
)
texture = texture .. banner_overlay
end
local marker = ""
if (
self._pos.x > self._minp.x and
self._pos.x < self._maxp.x and
self._pos.z > self._minp.z and
self._pos.z < self._maxp.z
) then
-- marker is 8×8, points downwards
local x = self._pos.x - self._minp.x - 3
local z = self._maxp.z - self._pos.z - 6
-- hack to avoid clipping
if x < 0 then x = 0 end
if z < 0 then z = 0 end
if x > 120 then x = 120 end
if z > 120 then z = 120 end
marker = "^[combine:8x8:" .. x .. "," .. z .. "=mcl_maps_itemframe_location_marker.png"
end
self.object:set_properties(
{
textures = { texture .. marker }
}
)
end,
get_staticdata = function(self)
local data = {
id = self.id,
_pos = self._pos,
_minp = self._minp,
_maxp = self._maxp,
_banners = self._banners,
}
return minetest.serialize(data)
end,
})
local facedir = {}
facedir[0] = {x=0,y=0,z=1}
@ -61,13 +132,10 @@ facedir[2] = {x=0,y=0,z=-1}
facedir[3] = {x=-1,y=0,z=0}
local remove_item_entity = function(pos, node)
local objs = nil
if node.name == "mcl_itemframes:item_frame" then
objs = minetest.get_objects_inside_radius(pos, .5)
end
if objs then
for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "mcl_itemframes:item" then
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
local entity = obj:get_luaentity()
if entity and (entity.name == "mcl_itemframes:item" or entity.name == "mcl_itemframes:map") then
obj:remove()
end
end
@ -89,25 +157,42 @@ local update_item_entity = function(pos, node, param2)
pos.y = pos.y + posad.y*6.5/16
pos.z = pos.z + posad.z*6.5/16
end
local e = minetest.add_entity(pos, "mcl_itemframes:item")
local lua = e:get_luaentity()
lua._nodename = node.name
local itemname = item:get_name()
if itemname == "" or itemname == nil then
lua._texture = "blank.png"
lua._scale = 1
else
lua._texture = itemname
local def = minetest.registered_items[itemname]
if def and def.wield_scale then
lua._scale = def.wield_scale.x
else
local yaw = math.pi*2 - param2 * math.pi/2
local meta = item:get_meta()
local map_id = meta:get_string("mcl_maps:id")
if map_id == "" then
local e = minetest.add_entity(pos, "mcl_itemframes:item")
local lua = e:get_luaentity()
lua._nodename = node.name
local itemname = item:get_name()
if itemname == "" or itemname == nil then
lua._texture = "blank.png"
lua._scale = 1
else
lua._texture = itemname
local def = minetest.registered_items[itemname]
lua._scale = def and def.wield_scale and def.wield_scale.x or 1
end
end
lua:_update_texture()
if node.name == "mcl_itemframes:item_frame" then
local yaw = math.pi*2 - param2 * math.pi/2
lua:_update_texture()
if node.name == "mcl_itemframes:item_frame" then
e:set_yaw(yaw)
end
else
local banners
local banners_string = meta:get_string("mcl_maps:banners")
if "" == banners_string then
banners = {}
else
banners = minetest.deserialize(banners_string)
end
local staticdata = {
id = map_id,
_pos = pos,
_minp = minetest.string_to_pos(meta:get_string("mcl_maps:minp")),
_maxp = minetest.string_to_pos(meta:get_string("mcl_maps:maxp")),
_banners = banners,
}
local e = minetest.add_entity(pos, "mcl_itemframes:map", minetest.serialize(staticdata))
e:set_yaw(yaw)
end
end

View File

@ -1,3 +1,3 @@
name = mcl_itemframes
depends = mcl_core, mcl_sounds
depends = mcl_core, mcl_sounds, mcl_maps
optional_depends = screwdriver

File diff suppressed because one or more lines are too long

View File

@ -1,93 +1,413 @@
local S = minetest.get_translator("mcl_maps")
mcl_maps = {
map_update_fps = tonumber(minetest.settings:get("mcl_maps_map_update_fps")) or 15
}
-- Turn empty map into filled map by rightclick
local make_filled_map = function(itemstack, placer, pointed_thing)
local new_map = ItemStack("mcl_maps:filled_map")
itemstack:take_item()
if itemstack:is_empty() then
return new_map
else
local inv = placer:get_inventory()
if inv:room_for_item("main", new_map) then
inv:add_item("main", new_map)
else
minetest.add_item(placer:get_pos(), new_map)
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
local math = math
local vector = vector
local table = table
local pairs = pairs
local pos_to_string = minetest.pos_to_string
local string_to_pos = minetest.string_to_pos
local get_item_group = minetest.get_item_group
local dynamic_add_media = minetest.dynamic_add_media
local get_connected_players = minetest.get_connected_players
local worldpath = minetest.get_worldpath()
local map_textures_path = worldpath .. "/mcl_maps/"
minetest.mkdir(map_textures_path)
local function load_json_file(name)
local file = assert(io.open(modpath .. "/" .. name .. ".json", "r"))
local data = minetest.parse_json(file:read())
file:close()
return data
end
local texture_colors = load_json_file("colors")
local palettes = load_json_file("palettes")
local color_cache = {}
local creating_maps = {}
local loaded_maps = {}
local c_air = minetest.get_content_id("air")
function mcl_maps.create_map(pos)
local minp = vector.multiply(vector.floor(vector.divide(pos, 128)), 128)
local maxp = vector.add(minp, vector.new(127, 127, 127))
local itemstack = ItemStack("mcl_maps:filled_map")
local meta = itemstack:get_meta()
local id = tostring(os.time() + math.random())
meta:set_string("mcl_maps:id", id)
meta:set_string("mcl_maps:minp", pos_to_string(minp))
meta:set_string("mcl_maps:maxp", pos_to_string(maxp))
tt.reload_itemstack_description(itemstack)
creating_maps[id] = true
minetest.emerge_area(minp, maxp, function(blockpos, action, calls_remaining)
if calls_remaining > 0 then
return
end
local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(minp, maxp)
local data = vm:get_data()
local param2data = vm:get_param2_data()
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local pixels = {}
local last_heightmap
for x = 1, 128 do
local map_x = minp.x - 1 + x
local heightmap = {}
for z = 1, 128 do
local map_z = minp.z - 1 + z
local color, height
for map_y = maxp.y, minp.y, -1 do
local index = area:index(map_x, map_y, map_z)
local c_id = data[index]
if c_id ~= c_air then
color = color_cache[c_id]
if color == nil then
local nodename = minetest.get_name_from_content_id(c_id)
local def = minetest.registered_nodes[nodename]
if def then
local texture
if def.palette then
texture = def.palette
elseif def.tiles then
texture = def.tiles[1]
if type(texture) == "table" then
texture = texture.name
end
end
if texture then
texture = texture:match("([^=^%^]-([^.]+))$"):split("^")[1]
end
if def.palette then
local palette = palettes[texture]
color = palette and {palette = palette}
else
color = texture_colors[texture]
end
end
end
if color and color.palette then
color = color.palette[param2data[index] + 1]
else
color_cache[c_id] = color or false
end
if color and last_heightmap then
local last_height = last_heightmap[z]
if last_height < map_y then
color = {
math.min(255, color[1] + 16),
math.min(255, color[2] + 16),
math.min(255, color[3] + 16),
}
elseif last_height > map_y then
color = {
math.max(0, color[1] - 16),
math.max(0, color[2] - 16),
math.max(0, color[3] - 16),
}
end
end
height = map_y
break
end
end
heightmap[z] = height or minp.y
pixels[z] = pixels[z] or {}
pixels[z][x] = color or {0, 0, 0}
end
last_heightmap = heightmap
end
tga_encoder.image(pixels):save(map_textures_path .. "mcl_maps_map_texture_" .. id .. ".tga")
creating_maps[id] = nil
end)
return itemstack
end
function mcl_maps.load_map(id)
if id == "" or creating_maps[id] then
return
end
local texture = "mcl_maps_map_texture_" .. id .. ".tga"
if not loaded_maps[id] then
if not minetest.features.dynamic_add_media_table then
-- minetest.dynamic_add_media() blocks in
-- Minetest 5.3 and 5.4 until media loads
loaded_maps[id] = true
dynamic_add_media(map_textures_path .. texture, function() end)
else
-- minetest.dynamic_add_media() never blocks
-- in Minetest 5.5, callback runs after load
dynamic_add_media(map_textures_path .. texture, function()
loaded_maps[id] = true
end)
end
end
if loaded_maps[id] then
return texture
end
end
local function encode_item_meta(input)
return minetest.encode_base64(
minetest.compress(
input,
"deflate",
9
)
)
end
local function decode_item_meta(input)
return minetest.decompress(
minetest.decode_base64(input),
"deflate",
9
)
end
result_original = "foo\0\01\02\x03\n\rbar"
result_roundtrip = decode_item_meta(
encode_item_meta(result_original)
)
assert(
result_original == result_roundtrip,
"mcl_maps: mismatch between encode_item_meta() and decode_item_meta()"
)
function mcl_maps.load_map_item(itemstack)
local meta = itemstack:get_meta()
local map_id = meta:get_string("mcl_maps:id")
if "" == map_id or creating_maps[map_id] then
-- wait for map content to be created
return
end
if loaded_maps[map_id] then
-- texture has already been sent
return mcl_maps.load_map(map_id)
end
local texture_file_name = "mcl_maps_map_texture_" .. map_id .. ".tga"
local texture_file_path = map_textures_path .. texture_file_name
-- does the texture file exist?
local texture_file_handle_read = io.open(
texture_file_path,
"rb"
)
local texture_file_exists = true
local texture_data_from_file
if nil == texture_file_handle_read then
texture_file_exists = false
else
texture_data_from_file = texture_file_handle_read:read("*a")
texture_file_handle_read:close()
end
-- does the texture item meta exist?
local tga_deflate_base64 = meta:get_string("mcl_maps:tga_deflate_base64")
local texture_item_meta_exists = true
if "" == tga_deflate_base64 then
texture_item_meta_exists = false
end
if texture_file_exists and nil ~= texture_data_from_file then
if texture_item_meta_exists then
-- sanity check: do we have the same textures?
-- if server-side texture has changed, take it
if decode_item_meta(tga_deflate_base64) ~= texture_data_from_file then
minetest.log(
"action",
"mcl_maps: update item meta from file content for map " .. map_id
)
meta:set_string(
"mcl_maps:tga_deflate_base64",
encode_item_meta(texture_data_from_file)
)
end
else
-- probably an older map from mcl2 or mcl5, so
-- we now write the file contents to item meta
minetest.log(
"action",
"mcl_maps: create item meta from file content for map " .. map_id
)
meta:set_string(
"mcl_maps:tga_deflate_base64",
encode_item_meta(texture_data_from_file)
)
end
else
-- no texture file → could be a world download
-- so we look for missing texture in item meta
-- and write that to the map texture file here
if texture_item_meta_exists then
minetest.log(
"action",
"mcl_maps: create file content from item meta for map " .. map_id
)
assert(
minetest.safe_file_write(
texture_file_path,
decode_item_meta(tga_deflate_base64)
)
)
else
minetest.log(
"error",
"no data for map " .. map_id
)
return
end
end
return mcl_maps.load_map(map_id)
end
local function fill_map(itemstack, placer, pointed_thing)
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
if minetest.settings:get_bool("enable_real_maps", true) then
local new_map = mcl_maps.create_map(placer:get_pos())
itemstack:take_item()
if itemstack:is_empty() then
return new_map
else
local inv = placer:get_inventory()
if inv:room_for_item("main", new_map) then
inv:add_item("main", new_map)
else
minetest.add_item(placer:get_pos(), new_map)
end
return itemstack
end
return itemstack
end
end
minetest.register_craftitem("mcl_maps:empty_map", {
description = S("Empty Map"),
_doc_items_longdesc = S("Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used."),
_doc_items_usagehelp = S("Rightclick to start using the map (which can't be stacked anymore)."),
_doc_items_usagehelp = S("Rightclick to create a filled map (which can't be stacked anymore)."),
inventory_image = "mcl_maps_map_empty.png",
groups = { not_in_creative_inventory = 1 },
on_place = make_filled_map,
on_secondary_use = make_filled_map,
on_place = fill_map,
on_secondary_use = fill_map,
stack_max = 64,
})
local function has_item_in_hotbar(player, item)
-- Requirement: player carries the tool in the hotbar
local inv = player:get_inventory()
local hotbar = player:hud_get_hotbar_itemcount()
for i=1, hotbar do
if inv:get_stack("main", i):get_name() == item then
return true
end
end
return false
end
-- Checks if player is still allowed to display the minimap
local function update_minimap(player)
local creative = minetest.is_creative_enabled(player:get_player_name())
local newstate=false
local oldstate=player:hud_get_flags().minimap
if creative or has_item_in_hotbar(player, "mcl_maps:filled_map") then
newstate=true
end
if oldstate ~= newstate then
if creative then
player:hud_set_flags({minimap = true, minimap_radar = true})
else
player:hud_set_flags({minimap = newstate, minimap_radar = false})
end
end
end
-- Remind player how to use the minimap correctly
local function use_minimap(itemstack, player, pointed_thing)
if player and player:is_player() then
update_minimap(player)
minetest.chat_send_player(player:get_player_name(), S("Use the minimap key to show the map."))
end
end
-- Enables minimap if carried in hotbar.
-- If this item is NOT in the hotbar, the minimap is unavailable
-- Note: This is not at all like Minecraft right now. Minetest's minimap is pretty overpowered, it
-- has a very greatly zoomed-out version and even a radar mode
minetest.register_craftitem("mcl_maps:filled_map", {
local filled_def = {
description = S("Map"),
_tt_help = S("Enables minimap"),
_doc_items_longdesc = S("Maps show your surroundings as you explore the world."),
_doc_items_usagehelp = S("Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).").."\n"..
S("In Creative Mode, you don't need this item; the minimap is always available."),
groups = { tool = 1 },
_tt_help = S("Shows a map image."),
_doc_items_longdesc = S("When created, the map saves the nearby area as an image that can be viewed any time by holding the map."),
_doc_items_usagehelp = S("Hold the map in your hand. This will display a map on your screen."),
inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)",
stack_max = 1,
stack_max = 64,
groups = { filled_map = 1, not_in_creative_inventory = 1, tool = 1 },
}
on_use = use_minimap,
on_secondary_use = use_minimap,
})
minetest.register_craftitem("mcl_maps:filled_map", filled_def)
local function add_marker(itemstack, placer, pointed_thing)
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
if "node" == pointed_thing.type then
local item_meta = itemstack:get_meta()
local node_pos = pointed_thing.under
local node = minetest.get_node(node_pos)
local name = node.name
if name == "mcl_banners:hanging_banner" or name == "mcl_banners:standing_banner" then
local banners_string = item_meta:get_string("mcl_maps:banners")
local banners_table
if "" == banners_string then
banners_table = {}
else
banners_table = minetest.deserialize(banners_string)
end
local colorid = mcl_banners.get_banner_colorid(node_pos)
local banner = {
node_pos,
colorid
}
table.insert(
banners_table,
banner
)
item_meta:set_string(
"mcl_maps:banners",
minetest.serialize(banners_table)
)
end
end
return itemstack
end
local filled_wield_def = table.copy(filled_def)
filled_wield_def.use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false
filled_wield_def.visual_scale = 1
filled_wield_def.wield_scale = {x = 1, y = 1, z = 1}
filled_wield_def.paramtype = "light"
filled_wield_def.drawtype = "mesh"
filled_wield_def.node_placement_prediction = ""
filled_wield_def.range = minetest.registered_items[""].range
filled_wield_def.on_place = add_marker
for _, texture in pairs(mcl_skins.list) do
local def = table.copy(filled_wield_def)
def.tiles = {texture .. ".png"}
def.mesh = "mcl_meshhand.b3d"
def._mcl_hand_id = texture
minetest.register_node("mcl_maps:filled_map_" .. texture, def)
local female_def = table.copy(def)
female_def.mesh = "mcl_meshhand_female.b3d"
female_def._mcl_hand_id = texture .. "_female"
minetest.register_node("mcl_maps:filled_map_" .. texture .. "_female", female_def)
end
local old_add_item = minetest.add_item
function minetest.add_item(pos, stack)
stack = ItemStack(stack)
if get_item_group(stack:get_name(), "filled_map") > 0 then
stack:set_name("mcl_maps:filled_map")
end
return old_add_item(pos, stack)
end
tt.register_priority_snippet(function(itemstring, _, itemstack)
if itemstack and get_item_group(itemstring, "filled_map") > 0 then
local id = itemstack:get_meta():get_string("mcl_maps:id")
if id ~= "" then
return "#" .. id, mcl_colors.GRAY
end
end
end)
minetest.register_craft({
output = "mcl_maps:filled_map",
output = "mcl_maps:empty_map",
recipe = {
{ "mcl_core:paper", "mcl_core:paper", "mcl_core:paper" },
{ "mcl_core:paper", "group:compass", "mcl_core:paper" },
@ -95,20 +415,197 @@ minetest.register_craft({
}
})
minetest.register_craft({
type = "shapeless",
output = "mcl_maps:filled_map 2",
recipe = {"group:filled_map", "mcl_maps:empty_map"},
})
local function on_craft(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() == "mcl_maps:filled_map" then
for _, stack in pairs(old_craft_grid) do
if get_item_group(stack:get_name(), "filled_map") > 0 then
itemstack:get_meta():from_table(stack:get_meta():to_table())
return itemstack
end
end
end
end
minetest.register_on_craft(on_craft)
minetest.register_craft_predict(on_craft)
local maps = {}
local huds = {}
local light = {}
minetest.register_on_joinplayer(function(player)
update_minimap(player)
local map_def = {
hud_elem_type = "image",
text = "blank.png",
position = {x = 0.75, y = 0.8},
alignment = {x = 0, y = -1},
offset = {x = 0, y = 0},
scale = {x = 2, y = 2},
}
local marker_def = table.copy(map_def)
marker_def.alignment = {x = 0, y = 0}
huds[player] = {
map = player:hud_add(map_def),
marker = player:hud_add(marker_def),
}
end)
local updatetimer = 0
if not minetest.is_creative_enabled("") then
minetest.register_globalstep(function(dtime)
updatetimer = updatetimer + dtime
if updatetimer > 0.1 then
local players = minetest.get_connected_players()
for i=1, #players do
update_minimap(players[i])
end
updatetimer = updatetimer - dtime
minetest.register_on_leaveplayer(function(player)
maps[player] = nil
light[player] = nil
huds[player] = nil
end)
function mcl_maps.make_banner_overlay(banners, minp, maxp, border)
local texture = ""
for i=1, #banners do
local banner_pos = banners[i][1]
local banner_colorid = banners[i][2]
local banner_hexcolor = mcl_banners.colorid_to_hexcolor(banner_colorid)
if (
banner_pos.x - 3 > minp.x and
banner_pos.x - 3 < maxp.x and
banner_pos.z - 7 > minp.z and
banner_pos.z - 7 < maxp.z
) then
local height = math.abs(maxp.x - minp.x) + border.top + border.bottom
local width = math.abs(maxp.z - minp.z) + border.left + border.right
-- marker is 8×8 & points down, map is 140×140
-- offsets have been experimentally determined
local banner_x = banner_pos.x - minp.x - 3 + border.left
local banner_z = maxp.z - banner_pos.z - 7 + border.top
texture = texture .. "^([combine:" .. width .. "x" .. height .. ":" .. banner_x .. "," .. banner_z .. "=mcl_maps_banner_location_marker.png^[colorize:" .. banner_hexcolor .. ":127)"
end
end)
end
return texture
end
local time_since_last_frame = 0
minetest.register_globalstep(function(dtime)
time_since_last_frame = time_since_last_frame + dtime
if time_since_last_frame < ( 1 / mcl_maps.map_update_fps ) then
return
end
time_since_last_frame = 0
for _, player in pairs(get_connected_players()) do
local wield = player:get_wielded_item()
local texture = mcl_maps.load_map_item(wield)
local hud = huds[player]
if texture then
local wield_def = wield:get_definition()
local hand_def = player:get_inventory():get_stack("hand", 1):get_definition()
if hand_def and wield_def and hand_def._mcl_hand_id ~= wield_def._mcl_hand_id then
wield:set_name("mcl_maps:filled_map_" .. hand_def._mcl_hand_id)
player:set_wielded_item(wield)
end
local pos = vector.round(player:get_pos())
local meta = wield:get_meta()
local minp = string_to_pos(meta:get_string("mcl_maps:minp"))
local maxp = string_to_pos(meta:get_string("mcl_maps:maxp"))
local banners_string = meta:get_string("mcl_maps:banners")
if "" ~= banners_string then
local banners = minetest.deserialize(banners_string)
if #banners > 0 then
local border = { top = 6, right = 6, bottom = 6, left = 6 }
local banner_overlay = mcl_maps.make_banner_overlay(
banners,
minp,
maxp,
border
)
texture = texture .. banner_overlay
end
end
local light_level
local light_level_overlay = ""
if nil ~= pos then -- do not crash while joining game
light_level = minetest.get_node_light(pos) or 0 -- can be nil somehow
light_level_overlay = "^[colorize:black:" .. 255 - (light_level * 17)
end
if texture ~= maps[player] or light_level ~= light[player] then
player:hud_change(hud.map, "text", "[combine:140x140:0,0=mcl_maps_map_background.png:6,6=" .. texture .. light_level_overlay)
if nil == maps[player] then
-- show tmp message if player
-- did not wield a map before
mcl_tmp_message.message(
player,
S("Right click on a banner to add a colored marker.")
)
end
light[player] = light_level
maps[player] = texture
end
local marker
if pos.x < minp.x then
if minp.x - pos.x < 256 then
marker = "mcl_maps_player_dot_large.png"
else
marker = "mcl_maps_player_dot.png"
end
pos.x = minp.x
elseif pos.x > maxp.x then
if pos.x - maxp.x < 256 then
marker = "mcl_maps_player_dot_large.png"
else
marker = "mcl_maps_player_dot.png"
end
pos.x = maxp.x
end
-- we never override the small marker
-- yes, this is a literal corner case
if pos.z < minp.z then
if minp.z - pos.z < 256 and marker ~= "mcl_maps_player_dot.png" then
marker = "mcl_maps_player_dot_large.png"
else
marker = "mcl_maps_player_dot.png"
end
pos.z = minp.z
elseif pos.z > maxp.z then
if pos.z - maxp.z < 256 and marker ~= "mcl_maps_player_dot.png" then
marker = "mcl_maps_player_dot_large.png"
else
marker = "mcl_maps_player_dot.png"
end
pos.z = maxp.z
end
if nil == marker then
local yaw = (math.floor(player:get_look_horizontal() * 180 / math.pi / 45 + 0.5) % 8) * 45
if yaw == 0 or
yaw == 90 or
yaw == 180 or
yaw == 270 then
marker = "mcl_maps_player_arrow.png" .. "^[transformR" .. yaw
end
if yaw == 45 or
yaw == 135 or
yaw == 225 or
yaw == 315 then
marker = "mcl_maps_player_arrow_diagonal.png" .. "^[transformR" .. (yaw - 45)
end
end
player:hud_change(hud.marker, "text", marker .. light_level_overlay)
player:hud_change(hud.marker, "offset", {x = (6 - 140 / 2 + pos.x - minp.x) * 2, y = (6 - 140 + maxp.z - pos.z) * 2})
elseif maps[player] then
player:hud_change(hud.map, "text", "blank.png")
player:hud_change(hud.marker, "text", "blank.png")
maps[player] = nil
end
end
end)

View File

@ -1,10 +1,8 @@
# textdomain: mcl_maps
Empty Map=Leere Karte
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Leere Karten sind als Karten nicht nützlich, aber sie können gestapelt werden und zu benutzbaren Karten umgewandelt werden.
Rightclick to start using the map (which can't be stacked anymore).=Rechtsklick, um zu beginnen, die Karte zu benutzen. Sie kann dann nicht mehr gestapelt werden.
Rightclick to create a filled map (which can't be stacked anymore).=Rechtsklick, um die Karte zu füllen. Sie kann dann nicht mehr gestapelt werden.
Map=Karte
Maps show your surroundings as you explore the world.=Karten zeigen Ihre Umgebung, während Sie die Welt erkunden.
Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Halten Sie die Karte in einen beliebigen Platz in der Schnellleiste. Damit können Sie jetzt die Übersichtskarte aktivieren, indem Sie die Taste zum Umschalten der Karte drücken (siehe Tastenbelegung).
In Creative Mode, you don't need this item; the minimap is always available.=Im Kreativmodus brauchen Sie diesen Gegenstand nicht; die Übersichtskarte ist immer verfügbar.
Enables minimap=Aktiviert Übersichtskarte
Use the minimap key to show the map.=Taste „Karte an/aus“ benutzen, um die Karte zu betrachten.
Shows a map image.=Zeigt ein Kartenbild.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Beim Erstellen speichert die Karte die Gegend in der Nähe als ein Bild, dass jederzeit durch halten der Karte angesehen werden kann.
Hold the map in your hand. This will display a map on your screen.=Halten Sie die Karte in Ihrer Hand. Eine Karte wird auf Ihrem Bildschirm angezeigt werden.

View File

@ -3,6 +3,3 @@ Empty Map=Mapa vacio
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Los mapas vacíos no son útiles como mapas, pero se pueden apilar y convertir en mapas que se pueden usar.
Rightclick to start using the map (which can't be stacked anymore).=Haga clic derecho para comenzar a usar el mapa (que ya no se puede apilar).
Map=Mapa
Maps show your surroundings as you explore the world.=Los mapas muestran tu entorno mientras exploras el mundo.
Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Mantenga el mapa en cualquiera de las ranuras de la barra de acceso directo. Esto le permite acceder al minimapa presionando la tecla del minimapa (consulte la configuración de los controles).
In Creative Mode, you don't need this item; the minimap is always available.=En el modo creativo, no necesita este elemento; El minimapa siempre está disponible.

View File

@ -1,10 +1,8 @@
# textdomain: mcl_maps
Empty Map=Carte Vierge
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Les cartes vierges ne sont pas utiles en tant que cartes, mais elles peuvent être empilées et transformées en cartes utilisables.
Rightclick to start using the map (which can't be stacked anymore).=Clic droit pour commencer à utiliser la carte (qui ne peut plus être empilée).
Rightclick to create a filled map (which can't be stacked anymore).=Clic droit pour créer une carte remplie (qui ne peut plus être empilée).
Map=Carte
Maps show your surroundings as you explore the world.=Les cartes montrent votre environnement lorsque vous explorez le monde.
Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Tenez la carte dans l'un des emplacements de la barre de raccourci. Cela vous permet d'accéder à la mini-carte en appuyant sur la touche de la mini-carte (voir les paramètres des commandes).
In Creative Mode, you don't need this item; the minimap is always available.=En mode créatif, vous n'avez pas besoin de cet élément; la minicarte est toujours disponible.
Enables minimap=Active la minicarte
Use the minimap key to show the map.=Utilisez la touche mini-carte pour afficher la carte.
Shows a map image.=Affiche une carte.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Lors de sa création, la carte sauvegarde le terrain proche sous forme d'image qui peut être consultée n'importe quand en tenant la carte dans la main.
Hold the map in your hand. This will display a map on your screen.=Tenez la carte dans votre main. Cela affichera la carte à l'écran.

View File

@ -0,0 +1,8 @@
# textdomain: mcl_maps
Empty Map=Pusta mapa
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Puste mapy nie są tak użyteczne jak mapy ale mogą być grupowane i zamienione w mapy które już są pożyteczne.
Rightclick to create a filled map (which can't be stacked anymore).=Kliknij prawy przycisk aby stworzyć wypełnioną mapę (nie będzie już jej można grupować).
Map=Mapa
Shows a map image.=Pokazuje obraz mapy.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Gdy są utworzone mapy zapisują obszar okolicy jako obrazek, który może być oglądany przez trzymanie mapy w rękach.
Hold the map in your hand. This will display a map on your screen.=Weź mapę do ręki. To pokaże mapę na twoim ekranie.

View File

@ -3,8 +3,3 @@ Empty Map=Пустая карта
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Пустые карты не могут использоваться в качестве карт, но могут складываться в стопки, а также могут быть превращены в полноценные карты.
Rightclick to start using the map (which can't be stacked anymore).=Кликните правой, чтобы начать использовать карту (её больше нельзя будет уложить в стопку).
Map=Карта
Maps show your surroundings as you explore the world.=Карты показывают ваше окружение, когда вы изучаете мир.
Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Поместите карту в один из отсеков панели быстрого доступа. Это позволит вам вызывать миникарту нажатием клавиши [Миникарта] (см. настройки управления).
In Creative Mode, you don't need this item; the minimap is always available.=Этот предмет не нужен в творческом режиме; там миникарта всегда доступна и так.
Enables minimap=Включает миникарту
Use the minimap key to show the map.=Используйте клавишу [Миникарта] для отображения карты.

View File

@ -1,10 +1,8 @@
# textdomain: mcl_maps
Empty Map=
Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=
Rightclick to start using the map (which can't be stacked anymore).=
Rightclick to create a filled map (which can't be stacked anymore).=
Map=
Maps show your surroundings as you explore the world.=
Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=
In Creative Mode, you don't need this item; the minimap is always available.=
Enables minimap=
Use the minimap key to show the map.=
Shows a map image.=
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=
Hold the map in your hand. This will display a map on your screen.=

View File

@ -1 +1,2 @@
name = mcl_maps
depends = mcl_banners, mcl_core, mcl_flowers, tga_encoder, tt, mcl_colors, mcl_skins, mcl_util, mcl_tmp_message

View File

@ -0,0 +1 @@
{"mcl_core_palette_grass.png": [[109, 196, 117], [159, 193, 114], [118, 177, 120], [118, 177, 120], [107, 186, 107], [118, 177, 120], [92, 182, 119], [92, 182, 119], [92, 182, 119], [92, 182, 119], [118, 177, 120], [109, 196, 117], [35, 175, 105], [94, 190, 107], [94, 190, 107], [94, 190, 107], [94, 190, 107], [159, 193, 114], [76, 176, 84], [164, 150, 110], [164, 150, 110], [164, 150, 110], [164, 150, 110], [159, 193, 114], [93, 181, 76], [93, 181, 76], [93, 181, 76], [93, 181, 76], [76, 118, 60], [94, 190, 107], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117], [109, 196, 117]]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

View File

@ -34,7 +34,8 @@ for _,texture in pairs(list) do
end,
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
range = def.range,
})
_mcl_hand_id = texture,
})
minetest.register_node("mcl_meshhand:"..texture.. "_female", {
description = "",
@ -57,7 +58,8 @@ for _,texture in pairs(list) do
end,
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
range = def.range,
})
_mcl_hand_id = texture .. "_female",
})
end
if has_mcl_skins == true then

View File

@ -102,6 +102,9 @@ animated_chests (Animated chests) bool true
# Whether to preview the player in inventory in 3D (requires Minetest 5.4)
3d_player_preview (3D Player preview) bool true
# How often the handheld map is updated per second
mcl_maps_map_update_fps (Map Update FPS) int 15 0 60
[Experimental]
# Whether ice is translucent. If disabled, ice is fully opaque.
#
@ -146,3 +149,6 @@ basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-ba
# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true.
fix_doubleplants (Mcimport double plant fixes) bool true
# Allow players to create Minecraft-like maps.
enable_real_maps (Enable Real Maps) bool true

View File

@ -196,6 +196,11 @@ def convert_textures():
if verbose:
print(src_file + "" + dst_file)
# Convert map background
map_background_file = tex_dir + "/map/map_background.png"
if os.path.isfile(map_background_file):
os.system("convert " + map_background_file + " -interpolate Integer -filter point -resize \"140x140\" " + target_dir("/mods/ITEMS/mcl_maps/textures") + "/mcl_maps_map_background.png")
# Convert armor textures (requires ImageMagick)
armor_files = [
[ tex_dir + "/models/armor/leather_layer_1.png", tex_dir + "/models/armor/leather_layer_2.png", target_dir("/mods/ITEMS/mcl_armor/textures"), "mcl_armor_helmet_leather.png", "mcl_armor_chestplate_leather.png", "mcl_armor_leggings_leather.png", "mcl_armor_boots_leather.png" ],

View File

@ -0,0 +1,59 @@
import sys, json, os
from PIL import Image
colors = {}
palettes = {}
for root, directories, files in os.walk(".."):
if root.endswith("/textures"):
for name in files:
try:
img = Image.open(os.path.join(root, name)).convert("RGBA")
pixels = img.load()
if "palette" in name:
palette = []
for y in range(0, img.size[1]):
for x in range(0, img.size[0]):
r, g, b, a = pixels[x, y]
palette.append((r, g, b))
palettes[name] = palette
else:
r_total = 0
g_total = 0
b_total = 0
count = 0
for x in range(0, img.size[0]):
for y in range(0, img.size[1]):
r, g, b, a = pixels[x, y]
if a > 0:
r_total += r / 255 * a
g_total += g / 255 * a
b_total += b / 255 * a
count += a / 255
average_color = None
if count > 0:
average_color = (int(r_total / count), int(g_total / count), int(b_total / count))
else:
average_color = (255, 255, 255)
colors[name] = average_color
img.close()
except IOError:
pass
path = "../mods/ITEMS/mcl_maps/"
with open(path + "colors.json", "w") as colorfile:
colorfile.write(json.dumps(colors))
with open(path + "palettes.json", "w") as palettefile:
palettefile.write(json.dumps(palettes))