1
0
Fork 0

Compare commits

...

19 Commits

Author SHA1 Message Date
Mikita Wiśniewski 271606cf27 Patch mcl_cocoas for pickblock 2024-08-18 11:14:54 +07:00
Mikita Wiśniewski f5249f1f31 Patch mcl_farming for pickblock 2024-08-18 11:14:54 +07:00
Mikita Wiśniewski a8712aece3 Patch mcl_mangrove for pickblock 2024-08-18 11:14:54 +07:00
Mikita Wiśniewski c3115a24b2 Patch mcl_beehives for pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 4996354995 Patch mcl_ocean/sea_pickle.lua for pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 128676d098 vl_pickblock: fix rightclick broken in survival 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 281c531533 Give slabs when pickblocking double slab blocks 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 5bbddda16a vl_pickblock: GOLD -> YELLOW 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 718ceb25cf Patch mcl_flowers for pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 02b24a9032 Refactor vl_pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski af092f35d9 Patch mcl_doors for pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 174ad29e0a Patch mcl_beds for pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski f8931ec5e2 Patch mcl_ocean for pickblock (again) 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 9ac416ee3e Notify the player if a picked block is already in their hotbar 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 077ea1828c Simplify pickblock implementation and call on_rightclick 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski ff590a93ae Patch mcl_brewing to work with pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 0af8b0ed59 Patch mcl_stairs to work with pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 3cac4f3037 Patch mcl_ocean to support pickblock 2024-08-18 11:14:53 +07:00
Mikita Wiśniewski 9d0e3ee7a2 Implement basic pickblock functionality (on rightclick) 2024-08-18 11:14:53 +07:00
24 changed files with 144 additions and 15 deletions

View File

@ -302,6 +302,7 @@ function mcl_beds.register_bed(name, def)
on_rotate = rotate,
after_destruct = destruct_bed,
on_dig = dig_bed,
_vl_pickblock = name .. "_bottom",
})
minetest.register_alias(name, name .. "_bottom")

View File

@ -129,6 +129,7 @@ for l = 1, 4 do
_mcl_hardness = 0.6,
drop = "",
after_dig_node = dig_hive,
_vl_pickblock = "mcl_beehives:beehive",
})
end
@ -148,6 +149,7 @@ minetest.register_node("mcl_beehives:beehive_5", {
on_rightclick = honey_harvest,
drop = "",
after_dig_node = dig_hive,
_vl_pickblock = "mcl_beehives:beehive",
})
-- Bee Nest
@ -184,6 +186,7 @@ for i = 1, 4 do
_mcl_hardness = 0.3,
drop = "",
after_dig_node = dig_hive,
_vl_pickblock = "mcl_beehives:bee_nest",
})
end
@ -203,6 +206,7 @@ minetest.register_node("mcl_beehives:bee_nest_5", {
on_rightclick = honey_harvest,
drop = "",
after_dig_node = dig_hive,
_vl_pickblock = "mcl_beehives:bee_nest",
})
-- Crafting

View File

@ -570,6 +570,7 @@ minetest.register_node("mcl_brewing:stand_100", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_010", {
@ -650,6 +651,7 @@ minetest.register_node("mcl_brewing:stand_010", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_001", {
@ -725,6 +727,7 @@ minetest.register_node("mcl_brewing:stand_001", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_110", {
@ -810,6 +813,7 @@ minetest.register_node("mcl_brewing:stand_110", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_101", {
@ -891,6 +895,7 @@ minetest.register_node("mcl_brewing:stand_101", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_011", {
@ -972,6 +977,7 @@ minetest.register_node("mcl_brewing:stand_011", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_node("mcl_brewing:stand_111", {
@ -1060,6 +1066,7 @@ minetest.register_node("mcl_brewing:stand_111", {
_mcl_hoppers_on_after_pull = function(pos)
on_put(pos, nil, nil, nil, nil)
end,
_vl_pickblock = "mcl_brewing:stand_000",
})
minetest.register_craft({

View File

@ -100,6 +100,7 @@ local crop_def = {
on_rotate = false,
_mcl_blast_resistance = 3,
_mcl_hardness = 0.2,
_vl_pickblock = "mcl_cocoas:cocoa_beans",
}
-- 2nd stage
@ -160,16 +161,16 @@ minetest.register_craftitem("mcl_cocoas:cocoa_beans", {
})
minetest.register_abm({
label = "Cocoa pod growth",
nodenames = {"mcl_cocoas:cocoa_1", "mcl_cocoas:cocoa_2"},
-- Same as potatoes
-- TODO: Tweak/balance the growth speed
interval = 50,
chance = 20,
action = function(pos, node)
mcl_cocoas.grow(pos)
end
} )
label = "Cocoa pod growth",
nodenames = {"mcl_cocoas:cocoa_1", "mcl_cocoas:cocoa_2"},
-- Same as potatoes
-- TODO: Tweak/balance the growth speed
interval = 50,
chance = 20,
action = function(pos, node)
mcl_cocoas.grow(pos)
end
})
-- Add entry aliases for the Help
if minetest.get_modpath("doc") then

View File

@ -327,6 +327,8 @@ function mcl_doors:register_door(name, def)
on_rotate = nil,
can_dig = check_player_priv,
_vl_pickblock = name,
}
local _b_1_def = table.copy(template_def)

View File

@ -236,6 +236,7 @@ function mcl_doors:register_trapdoor(name, def)
}
},
on_rotate = on_rotate,
_vl_pickblock = name,
})
-- Climbable opened
@ -267,6 +268,7 @@ function mcl_doors:register_trapdoor(name, def)
}
},
on_rotate = on_rotate,
_vl_pickblock = name,
})
if minetest.get_modpath("doc") then

View File

@ -36,6 +36,7 @@ minetest.register_node("mcl_farming:beetroot_0", {
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_blast_resistance = 0,
_vl_pickblock = "mcl_farming:beetroot_seeds",
})
minetest.register_node("mcl_farming:beetroot_1", {
@ -60,6 +61,7 @@ minetest.register_node("mcl_farming:beetroot_1", {
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_blast_resistance = 0,
_vl_pickblock = "mcl_farming:beetroot_seeds",
})
minetest.register_node("mcl_farming:beetroot_2", {
@ -84,6 +86,7 @@ minetest.register_node("mcl_farming:beetroot_2", {
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_blast_resistance = 0,
_vl_pickblock = "mcl_farming:beetroot_seeds",
})
minetest.register_node("mcl_farming:beetroot", {
@ -135,6 +138,7 @@ minetest.register_node("mcl_farming:beetroot", {
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,beetroot=4},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_farming:beetroot_seeds",
})
minetest.register_craftitem("mcl_farming:beetroot_item", {

View File

@ -45,6 +45,7 @@ for i=1, 7 do
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_blast_resistance = 0,
_vl_pickblock = "mcl_farming:carrot_item",
})
end
@ -84,7 +85,8 @@ minetest.register_node("mcl_farming:carrot", {
min_count = 2,
max_count = 4,
cap = 5,
}
},
_vl_pickblock = "mcl_farming:carrot_item",
})
minetest.register_craftitem("mcl_farming:carrot_item", {

View File

@ -109,6 +109,7 @@ for s=1,7 do
groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, plant_melon_stem=s},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_farming:melon_seeds",
})
end
@ -120,6 +121,7 @@ local stem_def = {
tiles = {"mcl_farming_melon_stem_disconnected.png^[colorize:#FFA800:127"},
wield_image = "mcl_farming_melon_stem_disconnected.png^[colorize:#FFA800:127",
inventory_image = "mcl_farming_melon_stem_disconnected.png^[colorize:#FFA800:127",
_vl_pickblock = "mcl_farming:melon_seeds",
}
-- Register stem growth

View File

@ -49,6 +49,7 @@ for i=1, 7 do
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_blast_resistance = 0,
_vl_pickblock = "mcl_farming:potato_item",
})
end
@ -89,7 +90,8 @@ minetest.register_node("mcl_farming:potato", {
min_count = 2,
max_count = 4,
cap = 5
}
},
_vl_pickblock = "mcl_farming:potato_item",
})
minetest.register_craftitem("mcl_farming:potato_item", {

View File

@ -79,6 +79,7 @@ for s=1,7 do
groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1,},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_farming:pumpkin_seeds",
})
end
@ -89,6 +90,7 @@ local stem_def = {
tiles = {"mcl_farming_pumpkin_stem_disconnected.png^[colorize:#FFA800:127"},
wield_image = "mcl_farming_pumpkin_stem_disconnected.png^[colorize:#FFA800:127",
inventory_image = "mcl_farming_pumpkin_stem_disconnected.png^[colorize:#FFA800:127",
_vl_pickblock = "mcl_farming:pumpkin_seeds",
}
-- Template for pumpkin

View File

@ -60,6 +60,7 @@ for i=1,7 do
dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_farming:wheat_seeds",
})
end
@ -95,7 +96,8 @@ minetest.register_node("mcl_farming:wheat", {
min_count = 1,
max_count = 6,
cap = 7
}
},
_vl_pickblock = "mcl_farming:wheat_seeds",
})
mcl_farming:add_plant("plant_wheat", "mcl_farming:wheat", {"mcl_farming:wheat_1", "mcl_farming:wheat_2", "mcl_farming:wheat_3", "mcl_farming:wheat_4", "mcl_farming:wheat_5", "mcl_farming:wheat_6", "mcl_farming:wheat_7"}, 25, 20)

View File

@ -383,7 +383,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
end,
groups = bottom_groups,
sounds = mcl_sounds.node_sound_leaves_defaults(),
mesh = mesh
mesh = mesh,
})
local top_groups = table.copy(bottom_groups)
@ -421,6 +421,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
end,
groups = top_groups,
sounds = mcl_sounds.node_sound_leaves_defaults(),
_vl_pickblock = "mcl_flowers:"..name,
})
if minetest.get_modpath("doc") and longdesc then

View File

@ -134,6 +134,7 @@ minetest.register_node("mcl_mangrove:hanging_propagule_1", {
tiles = {"mcl_mangrove_propagule_hanging.png"},
inventory_image = "mcl_mangrove_propagule.png",
wield_image = "mcl_mangrove_propagule.png",
_vl_pickblock = "mcl_mangrove:propagule",
})
local propagule_rooted_nodes = {}
for _,root in pairs(propagule_water_nodes) do
@ -172,6 +173,7 @@ for _,root in pairs(propagule_water_nodes) do
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_mcl_silk_touch_drop = true,
_vl_pickblock = "mcl_mangrove:propagule",
})
end
@ -240,6 +242,7 @@ local wlroots = {
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
end
end,
_vl_pickblock = "mcl_mangrove:mangrove_roots",
}
local rwlroots = table.copy(wlroots)
-- FIXME luacheck complains that this is a repeated definition of water_tex.

View File

@ -547,7 +547,7 @@ kelp.surface_deftemplate = {
},
},
-- groups.falling_node = is_falling,
groups = { dig_immediate = 3, deco_block = 1, plant = 1, kelp = 1, },
groups = { dig_immediate = 3, deco_block = 1, plant = 1, kelp = 1, not_in_creative_inventory = 1 },
--sounds = sounds,
--node_dig_prediction = nodename,
on_construct = kelp.surface_on_construct,
@ -559,6 +559,7 @@ kelp.surface_deftemplate = {
--_mcl_falling_node_alternative = is_falling and nodename or nil,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_ocean:kelp",
}
-- Commented properties are the ones obtained using register_kelp_surface.

View File

@ -134,6 +134,7 @@ for s=1,4 do
_mcl_sea_pickle_next = next_on,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_vl_pickblock = canonical,
})
minetest.register_node("mcl_ocean:sea_pickle_"..s.."_off_"..ontop, {
@ -166,6 +167,7 @@ for s=1,4 do
_mcl_sea_pickle_next = next_off,
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_vl_pickblock = canonical,
})
if mod_doc then

View File

@ -140,6 +140,7 @@ for s=1, #surfaces do
_mcl_shears_drop = { "mcl_ocean:seagrass" },
_mcl_hardness = 0,
_mcl_blast_resistance = 0,
_vl_pickblock = "mcl_ocean:seagrass",
})
if mod_doc and surfaces[s][1] ~= "dirt" then
doc.add_entry_alias("nodes", "mcl_ocean:seagrass_dirt", "nodes", "mcl_ocean:seagrass_"..surfaces[s][1])

View File

@ -313,6 +313,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti
topdef._doc_items_usagehelp = nil
topdef.drop = lower_slab
topdef._mcl_other_slab_half = lower_slab
topdef._vl_pickblock = lower_slab
function topdef.on_rotate(pos, node, user, mode, param2)
-- Flip slab
if mode == screwdriver.ROTATE_AXIS then
@ -349,6 +350,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti
drop = lower_slab .. " 2",
_mcl_hardness = hardness,
_mcl_blast_resistance = blast_resistance,
_vl_pickblock = lower_slab,
})
if recipeitem then

View File

@ -665,6 +665,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles)
after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
_mcl_hardness = node_def._mcl_hardness,
on_rotate = false,
_vl_pickblock = name,
})
minetest.register_node(":"..name.."_inner", {
description = node_def.description,
@ -689,6 +690,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles)
after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
_mcl_hardness = node_def._mcl_hardness,
on_rotate = false,
_vl_pickblock = name,
})
if minetest.get_modpath("doc") then

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,46 @@
local S = minetest.get_translator("vl_pickblock")
local function pickblock(itemstack, placer, pointed_thing)
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)
local illegal = (def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0)
if illegal then
if def._vl_pickblock then
rnode = def._vl_pickblock
end
else
rnode = node.name
end
-- check if the picked node is already on the hotbar
-- if so, notify the player
local inv = placer:get_inventory()
for i=1,placer:hud_get_hotbar_itemcount() do
local stack = inv:get_stack("main", i)
if stack:get_name() == rnode then
local msg = S("@1 is on slot @2", stack:get_short_description(), minetest.colorize(mcl_colors.YELLOW, i))
mcl_title.set(placer, "actionbar", {text = msg, stay = 30})
return
end
end
return rnode
end
minetest.override_item("", {
on_place = function(itemstack, placer, pointed_thing)
if mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) then
return
elseif minetest.is_creative_enabled(placer:get_player_name()) then
return pickblock(itemstack, placer, pointed_thing)
end
end
})

View File

@ -0,0 +1,2 @@
# textdomain: vl_pickblock
@1 is on slot @2=

View File

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