Fix Licensing.

Removed Make_Stairs check.
Made unified protection check.
Began work on the second half of scaffolding.
Removed comments that was no longer needed.
This commit is contained in:
Michieal 2022-12-25 07:30:31 -05:00
parent c55332bf42
commit 6f05992c8b
3 changed files with 145 additions and 124 deletions

View File

@ -3,9 +3,9 @@ mcl_bamboo
This mod adds minecraft-like bamboo nodes to your Mineclone 2 world.
Code: Michieal. Original (basic) bamboo code by: Krock.
Code: Michieal. Original (basic) bamboo code by: Small Joker.
License for code: GPL3; images / textures: CC-BY-SA.
License for code / images / textures: CC-BY-SA.
Images Created by Michieal, except for:
Inventory / wield image: created by RandomLegoBrick#8692 and is CC0.
@ -15,7 +15,7 @@ Optional Dependencies = mcl_flowerpots, mclx_stairs, mcl_doors, mcl_signs, mesec
Special thanks to Nicu for help with the nodebox stalk design.
Krock's bamboo forum topic:
Small Joker's bamboo forum topic:
Forum topic: https://forum.minetest.net/viewtopic.php?id=8289
Scaffold inspiration: Cora, because she said that it couldn't be done.

View File

@ -14,7 +14,6 @@ local adj_nodes = {
vector.new(1, 0, 0),
vector.new(-1, 0, 0),
}
local SIDE_SCAFFOLDING = false
local function bambootoo_create_nodes()
local bamboo_mosaic = minetest.registered_nodes[bamboo .. "_plank"]
@ -24,7 +23,6 @@ local function bambootoo_create_nodes()
bamboo_mosaic._doc_items_longdesc = S("Bamboo Mosaic Plank")
minetest.register_node("mcl_bamboo:bamboo_mosaic", bamboo_mosaic)
-- crafted by "mcl_stair:slab_bamboo_plank", "mcl_stair:slab_bamboo_block", "mcl_stair:slab_bamboo_stripped"
if minetest.get_modpath("mcl_stairs") then
if mcl_stairs ~= nil then
mcl_stairs.register_stair_and_slab_simple(
@ -37,47 +35,60 @@ local function bambootoo_create_nodes()
end
end
if SIDE_SCAFFOLDING then
--currently, disabled.
minetest.register_node("mcl_bamboo:scaffolding_horizontal", {
description = S("Scaffolding (horizontal)"),
doc_items_longdesc = S("Scaffolding block used to climb up or out across areas."),
doc_items_hidden = false,
tiles = {"mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_bottom.png"},
drawtype = "nodebox",
paramtype = "light",
use_texture_alpha = "clip",
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.375, -0.5, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, -0.375, 0.5, -0.375},
{0.375, -0.5, -0.5, 0.5, 0.5, -0.375},
{0.375, -0.5, 0.375, 0.5, 0.5, 0.5},
{-0.5, -0.5, 0.375, -0.375, 0.5, 0.5},
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
}
minetest.register_node("mcl_bamboo:scaffolding_horizontal", {
description = S("Scaffolding (horizontal)"),
doc_items_longdesc = S("Scaffolding block used to climb up or out across areas."),
doc_items_hidden = false,
tiles = {"mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_bottom.png"},
drop = "mcl_bamboo:scaffolding",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "4dir",
param2 = 0,
use_texture_alpha = "clip",
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.375, -0.5, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, -0.375, 0.5, -0.375},
{0.375, -0.5, -0.5, 0.5, 0.5, -0.375},
{0.375, -0.5, 0.375, 0.5, 0.5, 0.5},
{-0.5, -0.5, 0.375, -0.375, 0.5, 0.5},
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
groups = {handy = 1, axey = 1, flammable = 3, building_block = 1, material_wood = 1, fire_encouragement = 5, fire_flammability = 20, not_in_creative_inventory = 1, falling_node = 1},
_mcl_after_falling = function(pos)
if minetest.get_node(pos).name == "mcl_bamboo:scaffolding_horizontal" then
if minetest.get_node(vector.offset(pos, 0, 0, 0)).name ~= "mcl_bamboo:scaffolding" then
minetest.remove_node(pos)
minetest.add_item(pos, "mcl_bamboo:scaffolding")
else
minetest.set_node(vector.offset(pos, 0, 1, 0), {name = "mcl_bamboo:scaffolding"})
end
},
groups = {handy = 1, axey = 1, flammable = 3, building_block = 1, material_wood = 1, fire_encouragement = 5, fire_flammability = 20, not_in_creative_inventory = 1, falling_node = 1},
_mcl_after_falling = function(pos)
if minetest.get_node(pos).name == "mcl_bamboo:scaffolding_horizontal" then
if minetest.get_node(vector.offset(pos, 0, 0, 0)).name ~= "mcl_bamboo:scaffolding" then
minetest.remove_node(pos)
minetest.add_item(pos, "mcl_bamboo:scaffolding")
else
minetest.set_node(vector.offset(pos, 0, 1, 0), {name = "mcl_bamboo:scaffolding"})
end
end
})
end
end,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local node = minetest.get_node(pointed_thing.under)
local pos = pointed_thing.under
if mcl_bamboo.is_protected(pos, placer) then
return
end
end
})
end

View File

@ -1,7 +1,8 @@
-- [bamboo] mod by SmallJoker, Made for MineClone 2 by Michieal (as mcl_bamboo).
-- Parts of mcl_scaffolding were used. Mcl_scaffolding originally created by Cora; heavily reworked for mcl_bamboo by Michieal.
-- Parts of mcl_scaffolding were used. Mcl_scaffolding originally created by Cora; Fixed and heavily reworked
-- for mcl_bamboo by Michieal.
-- Creation date: 12-01-2022 (Dec 1st, 2022)
-- License for everything: GPL3
-- License for everything: CC-BY-SA 4.0
-- Bamboo max height: 12-16
-- LOCALS
@ -13,10 +14,21 @@ local node_sound = mcl_sounds.node_sound_wood_defaults()
-- CONSTS
local SIDE_SCAFFOLDING = false
local MAKE_STAIRS = true
local DEBUG = false
local DOUBLE_DROP_CHANCE = 8
mcl_bamboo ={}
--- pos: node position; placer: ObjectRef that is placing the item
--- returns: true if protected, otherwise false.
function mcl_bamboo.is_protected(pos, placer)
local name = placer:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return true
end
return false
end
--Bamboo can be planted on moss blocks, grass blocks, dirt, coarse dirt, rooted dirt, gravel, mycelium, podzol, sand, red sand, or mud
local bamboo_dirt_nodes = {
@ -38,7 +50,7 @@ local BROKEN_DOORS = true
-- LOCAL FUNCTIONS
-- Add Groups function, courtesy of Warr1024.
function addgroups(name, ...)
function mcl_bamboo.addgroups(name, ...)
local def = minetest.registered_items[name] or error(name .. " not found")
local groups = {}
for k, v in pairs(def.groups) do
@ -124,9 +136,7 @@ local function create_nodes()
if DEBUG then
minetest.log("mcl_bamboo::Checking for protected placement of bamboo.")
end
local pname = placer:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
if mcl_bamboo.is_protected(pos, placer) then
return
end
if DEBUG then
@ -224,9 +234,7 @@ local function create_nodes()
local pos = pointed_thing.under
local pname = placer:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
if mcl_bamboo.is_protected(pos, placer) then
return
end
@ -335,47 +343,45 @@ local function create_nodes()
end
end
if MAKE_STAIRS then
if minetest.get_modpath("mcl_stairs") then
if mcl_stairs ~= nil then
mcl_stairs.register_stair_and_slab_simple(
"bamboo_block",
"mcl_bamboo:bamboo_block",
S("Bamboo Stair"),
S("Bamboo Slab"),
S("Double Bamboo Slab")
)
mcl_stairs.register_stair_and_slab_simple(
"bamboo_stripped",
"mcl_bamboo:bamboo_block_stripped",
S("Stripped Bamboo Stair"),
S("Stripped Bamboo Slab"),
S("Double Stripped Bamboo Slab")
)
mcl_stairs.register_stair_and_slab_simple(
"bamboo_plank",
"mcl_bamboo:bamboo_plank",
S("Bamboo Plank Stair"),
S("Bamboo Plank Slab"),
S("Double Bamboo Plank Slab")
)
if minetest.get_modpath("mcl_stairs") then
if mcl_stairs ~= nil then
mcl_stairs.register_stair_and_slab_simple(
"bamboo_block",
"mcl_bamboo:bamboo_block",
S("Bamboo Stair"),
S("Bamboo Slab"),
S("Double Bamboo Slab")
)
mcl_stairs.register_stair_and_slab_simple(
"bamboo_stripped",
"mcl_bamboo:bamboo_block_stripped",
S("Stripped Bamboo Stair"),
S("Stripped Bamboo Slab"),
S("Double Stripped Bamboo Slab")
)
mcl_stairs.register_stair_and_slab_simple(
"bamboo_plank",
"mcl_bamboo:bamboo_plank",
S("Bamboo Plank Stair"),
S("Bamboo Plank Slab"),
S("Double Bamboo Plank Slab")
)
-- let's add plank slabs to the wood_slab group.
local bamboo_plank_slab = "mcl_stairs:slab_bamboo_plank"
local node_groups = {
wood_slab = 1,
building_block = 1,
slab = 1,
axey = 1,
handy = 1,
stair = 1,
flammable = 1,
fire_encouragement = 5,
fire_flammability = 20
}
-- let's add plank slabs to the wood_slab group.
local bamboo_plank_slab = "mcl_stairs:slab_bamboo_plank"
local node_groups = {
wood_slab = 1,
building_block = 1,
slab = 1,
axey = 1,
handy = 1,
stair = 1,
flammable = 1,
fire_encouragement = 5,
fire_flammability = 20
}
minetest.override_item(bamboo_plank_slab, {groups = node_groups})
end
minetest.override_item(bamboo_plank_slab, {groups = node_groups})
end
end
@ -502,6 +508,8 @@ local function create_nodes()
tiles = {"mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_top.png", "mcl_bamboo_scaffolding_bottom.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "4dir",
param2 = 0,
use_texture_alpha = "clip",
node_box = {
type = "fixed",
@ -552,9 +560,7 @@ local function create_nodes()
end
local node = minetest.get_node(ptd.under)
local pos = ptd.under
local pname = placer:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
if mcl_bamboo.is_protected(pos, placer) then
return
end
if DEBUG then
@ -715,37 +721,41 @@ local function register_craftings()
burntime = 20
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_plank",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_block",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_stripped",
burntime = 7.5,
})
if minetest.get_modpath("mcl_stairs") then
if mcl_stairs ~= nil then
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_plank",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_block",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:slab_bamboo_stripped",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_plank",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_block",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_stripped",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_plank",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_block",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_stairs:stair_bamboo_stripped",
burntime = 15,
})
end
end
minetest.register_craft({
type = "fuel",