Implement basic pickblock functionality (on rightclick)

This commit is contained in:
Mikita Wiśniewski 2024-07-31 20:38:29 +07:00
parent 0012bdb71e
commit 1346039022
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2022 ROllerozxa
Copyright (c) 2024 Mikita 'rudzik8' Wiśniewski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,13 @@
# `vl_pickblock`
Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.
You select them with the build key (right-click) as compared to with middle-click as it usually is in Minecraft.
## License
Copyright (C) 2022 ROllerozxa\
Copyright (C) 2024 Mikita 'rudzik8' Wiśniewski
MIT (see `LICENSE` file)

View File

@ -0,0 +1,25 @@
minetest.override_item("", {
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_creative_enabled(placer:get_player_name()) then
local node = minetest.get_node_or_nil(pointed_thing.under)
if not node then return end
local def = minetest.registered_nodes[node.name]
if not def then return end
local rnode
-- if this is an 'illegal' node and there's an explicit `_vl_pickblock` field, then return it
-- if the node isn't 'illegal', return it as-is
-- (and if it's 'illegal' and no `_vl_pickblock` is defined, well, bad luck)
if def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0 then
if def._vl_pickblock then
rnode = def._vl_pickblock
end
else
rnode = node.name
end
return {name = rnode}
end
end
})

View File

@ -0,0 +1,2 @@
name = vl_pickblock
description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.