Simplify rotation of pillar-like nodes

This commit is contained in:
Wuzzy 2019-12-14 23:42:17 +01:00
parent 44c95084ab
commit 92ef7c3b9a
8 changed files with 68 additions and 0 deletions

@ -1,6 +1,12 @@
-- Other nodes
local S = minetest.get_translator("mcl_core")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_3way
end
minetest.register_node("mcl_core:bone_block", {
description = S("Bone Block"),
_doc_items_longdesc = S("Bone blocks are decorative blocks and a compact storage of bone meal."),
@ -10,6 +16,7 @@ minetest.register_node("mcl_core:bone_block", {
on_place = mcl_util.rotate_axis,
groups = {pickaxey=1, building_block=1, material_stone=1},
sounds = mcl_sounds.node_sound_stone_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 10,
_mcl_hardness = 2,
})

@ -1,6 +1,12 @@
-- Tree nodes: Wood, Wooden Planks, Sapling, Leaves
local S = minetest.get_translator("mcl_core")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_3way
end
-- Register tree trunk (wood) and bark
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark)
minetest.register_node("mcl_core:"..subname, {
@ -13,6 +19,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
stack_max = 64,
groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1},
sounds = mcl_sounds.node_sound_wood_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 10,
_mcl_hardness = 2,
})
@ -27,6 +34,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1},
sounds = mcl_sounds.node_sound_wood_defaults(),
is_ground_content = false,
on_rotate = on_rotate,
_mcl_blast_resistance = 10,
_mcl_hardness = 2,
})

@ -1,6 +1,12 @@
-- Building blocks and decorative nodes
local S = minetest.get_translator("mcl_end")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_3way
end
minetest.register_node("mcl_end:end_stone", {
description = S("End Stone"),
_doc_items_longdesc = doc.sub.items.temp.build,
@ -47,6 +53,7 @@ minetest.register_node("mcl_end:purpur_pillar", {
tiles = {"mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar.png"},
groups = {pickaxey=1, building_block=1, material_stone=1, purpur_block=1},
sounds = mcl_sounds.node_sound_stone_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 30,
_mcl_hardness = 1.5,
})

@ -1,5 +1,11 @@
local S = minetest.get_translator("mcl_farming")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_simple
end
-- Seeds
minetest.register_craftitem("mcl_farming:pumpkin_seeds", {
description = S("Pumpkin Seeds"),
@ -93,6 +99,7 @@ local pumpkin_base_def = {
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png"},
groups = {handy=1,axey=1, plant=1,building_block=1, dig_by_piston=1, enderman_takable=1},
sounds = mcl_sounds.node_sound_wood_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 5,
_mcl_hardness = 1,
}
@ -134,6 +141,7 @@ minetest.register_node("mcl_farming:pumpkin_face_light", {
mobs_mc.tools.check_iron_golem_summon(pos)
mobs_mc.tools.check_snow_golem_summon(pos)
end,
on_rotate = on_rotate,
_mcl_blast_resistance = 5,
_mcl_hardness = 1,
})

@ -130,6 +130,12 @@ minetest.register_craftitem("mcl_farming:bread", {
on_secondary_use = minetest.item_eat(5),
})
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_3way
end
minetest.register_node("mcl_farming:hay_block", {
description = S("Hay Bale"),
_doc_items_longdesc = S("Hay bales are decorative blocks made from wheat."),
@ -141,6 +147,7 @@ minetest.register_node("mcl_farming:hay_block", {
on_place = mcl_util.rotate_axis,
groups = {handy=1, flammable=2, building_block=1, fall_damage_add_percent=-80},
sounds = mcl_sounds.node_sound_leaves_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 2.5,
_mcl_hardness = 0.5,
})

@ -5,3 +5,4 @@ walkover
mcl_death_messages?
doc_items
doc?
screwdriver?

@ -1,6 +1,11 @@
local S = minetest.get_translator("mcl_nether")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_3way
end
minetest.register_node("mcl_nether:glowstone", {
description = S("Glowstone"),
@ -201,6 +206,7 @@ minetest.register_node("mcl_nether:quartz_pillar", {
tiles = {"mcl_nether_quartz_pillar_top.png", "mcl_nether_quartz_pillar_top.png", "mcl_nether_quartz_pillar_side.png"},
groups = {pickaxey=1, quartz_block=1,building_block=1, material_stone=1},
sounds = mcl_sounds.node_sound_stone_defaults(),
on_rotate = on_rotate,
_mcl_blast_resistance = 4,
_mcl_hardness = 0.8,
})

@ -12,6 +12,30 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2)
return false
end
end
screwdriver.rotate_3way = function(pos, node, user, mode, new_param2)
if mode == screwdriver.ROTATE_AXIS then
if node.param2 == 0 then
node.param2 = 6
elseif node.param2 == 6 then
node.param2 = 12
else
node.param2 = 0
end
minetest.swap_node(pos, node)
return true
elseif mode == screwdriver.ROTATE_FACE then
if node.param2 == 6 then
node.param2 = 12
minetest.swap_node(pos, node)
return true
else
node.param2 = 6
minetest.swap_node(pos, node)
return true
end
end
return false
end
-- For attached wallmounted nodes: returns true if rotation is valid
-- simplified version of minetest:builtin/game/falling.lua#L148.