Merge testing into compatibility

This commit is contained in:
kay27 2022-03-21 15:35:59 +04:00
commit d2ef621604
36 changed files with 583 additions and 485 deletions

View File

@ -71,6 +71,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
* `coral_block=X`: Coral block (1 = alive, 2 = dead) * `coral_block=X`: Coral block (1 = alive, 2 = dead)
* `coral_species=X`: Specifies the species of a coral; equal X means equal species * `coral_species=X`: Specifies the species of a coral; equal X means equal species
* `set_on_fire=X`: Sets any (not fire-resistant) mob or player on fire for X seconds when touching * `set_on_fire=X`: Sets any (not fire-resistant) mob or player on fire for X seconds when touching
* `compostability`: Amount from 1 to 100 that defines the percentage of likelyhood that the composter will advance a level.
#### Footnotes #### Footnotes

View File

@ -325,7 +325,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
-- mcl_mapgen.register_mapgen_lvm(function(vm_context), order_number) -- -- mcl_mapgen.register_mapgen_lvm(function(vm_context), order_number) --
-- -- -- --
for _, v in pairs(queue_chunks_lvm) do for _, v in pairs(queue_chunks_lvm) do
vm_context = v.f(vm_context) v.f(vm_context)
end end
-- -- -- --
-- mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed, vm_context), order_number) -- -- mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed, vm_context), order_number) --

View File

@ -152,3 +152,23 @@ minetest.register_globalstep(function(dtime)
dimtimer = 0 dimtimer = 0
end end
end) end)
function mcl_worlds.get_cloud_parameters()
if mcl_mapgen.name == "valleys" then
return {
height = 384,
speed = {x=-2, z=0},
thickness=5,
color="#FFF0FEF",
ambient = "#201060",
}
else
-- MC-style clouds: Layer 127, thickness 4, fly to the “West”
return {
height = mcl_worlds.layer_to_y(127),
speed = {x=-2, z=0},
thickness = 4,
color = "#FFF0FEF",
}
end
end

View File

@ -401,6 +401,7 @@ function mobs:register_mob(name, def)
ignited_by_sunlight = def.ignited_by_sunlight or false, ignited_by_sunlight = def.ignited_by_sunlight or false,
eye_height = def.eye_height or 1.5, eye_height = def.eye_height or 1.5,
defuse_reach = def.defuse_reach or 4, defuse_reach = def.defuse_reach or 4,
spawn = def.spawn,
-- End of MCL2 extensions -- End of MCL2 extensions
on_spawn = def.on_spawn, on_spawn = def.on_spawn,

View File

@ -267,6 +267,8 @@ function mobs:spawn_setup(def)
local day_toggle = def.day_toggle local day_toggle = def.day_toggle
local on_spawn = def.on_spawn local on_spawn = def.on_spawn
local check_position = def.check_position local check_position = def.check_position
local group_size_min = def.group_size_min or 1
local group_size_max = def.group_size_max or 1
-- chance/spawn number override in minetest.conf for registered mob -- chance/spawn number override in minetest.conf for registered mob
local numbers = minetest.settings:get(name) local numbers = minetest.settings:get(name)
@ -300,10 +302,23 @@ function mobs:spawn_setup(def)
day_toggle = day_toggle, day_toggle = day_toggle,
check_position = check_position, check_position = check_position,
on_spawn = on_spawn, on_spawn = on_spawn,
group_size_min = group_size_min,
group_size_max = group_size_max,
} }
summary_chance = summary_chance + chance summary_chance = summary_chance + chance
end end
function mobs.spawn_mob(name, pos)
local def = minetest.registered_entities[name]
if not def then return end
if def.spawn then
return def.spawn(pos)
end
return minetest.add_entity(pos, name)
end
local spawn_mob = mobs.spawn_mob
function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn) function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
-- Do mobs spawn at all? -- Do mobs spawn at all?
@ -341,6 +356,8 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh
spawn_dictionary[key]["min_height"] = min_height spawn_dictionary[key]["min_height"] = min_height
spawn_dictionary[key]["max_height"] = max_height spawn_dictionary[key]["max_height"] = max_height
spawn_dictionary[key]["day_toggle"] = day_toggle spawn_dictionary[key]["day_toggle"] = day_toggle
spawn_dictionary[key]["group_size_min"] = 1
spawn_dictionary[key]["group_size_max"] = 3
summary_chance = summary_chance + chance summary_chance = summary_chance + chance
end end
@ -442,9 +459,9 @@ if mobs_spawn then
and (mob_def.check_position and mob_def.check_position(spawning_position) or true) and (mob_def.check_position and mob_def.check_position(spawning_position) or true)
then then
--everything is correct, spawn mob --everything is correct, spawn mob
local object = minetest.add_entity(spawning_position, mob_def.name) local object = spawn_mob(mob_def.name, spawning_position)
if object then if object then
return mob_def.on_spawn and mob_def.on_spawn(object, pos) return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position)
end end
end end
current_summary_chance = current_summary_chance - mob_chance current_summary_chance = current_summary_chance - mob_chance

View File

@ -2,118 +2,27 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local rabbit = { local mob_name = "mobs_mc:rabbit"
description = S("Rabbit"),
type = "animal",
spawn_class = "passive",
passive = true,
reach = 1,
rotate = 270,
hp_min = 3,
hp_max = 3,
xp_min = 1,
xp_max = 3,
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.49, 0.2},
visual = "mesh", local textures = {
mesh = "mobs_mc_rabbit.b3d",
textures = {
{"mobs_mc_rabbit_brown.png"}, {"mobs_mc_rabbit_brown.png"},
{"mobs_mc_rabbit_gold.png"}, {"mobs_mc_rabbit_gold.png"},
{"mobs_mc_rabbit_white.png"}, {"mobs_mc_rabbit_white.png"},
{"mobs_mc_rabbit_white_splotched.png"}, {"mobs_mc_rabbit_white_splotched.png"},
{"mobs_mc_rabbit_salt.png"}, {"mobs_mc_rabbit_salt.png"},
{"mobs_mc_rabbit_black.png"}, {"mobs_mc_rabbit_black.png"},
},
visual_size = {x=1.5, y=1.5},
sounds = {
random = "mobs_mc_rabbit_random",
damage = "mobs_mc_rabbit_hurt",
death = "mobs_mc_rabbit_death",
attack = "mobs_mc_rabbit_attack",
eat = "mobs_mc_animal_eat_generic",
distance = 16,
},
makes_footstep_sound = false,
walk_velocity = 1,
run_velocity = 3.7,
follow_velocity = 1.1,
floats = 1,
runaway = true,
jump = true,
drops = {
{name = mobs_mc.items.rabbit_raw, chance = 1, min = 0, max = 1, looting = "common",},
{name = mobs_mc.items.rabbit_hide, chance = 1, min = 0, max = 1, looting = "common",},
{name = mobs_mc.items.rabbit_foot, chance = 10, min = 0, max = 1, looting = "rare", looting_factor = 0.03,},
},
fear_height = 4,
animation = {
speed_normal = 25, speed_run = 50,
stand_start = 0, stand_end = 0,
walk_start = 0, walk_end = 20,
run_start = 0, run_end = 20,
},
-- Follow (yellow) dangelions, carrots and golden carrots
follow = mobs_mc.follow.rabbit,
view_range = 8,
-- Eat carrots and reduce their growth stage by 1
replace_rate = 10,
replace_what = mobs_mc.replace.rabbit,
on_rightclick = function(self, clicker)
-- Feed, tame protect or capture
if mobs:feed_tame(self, clicker, 1, true, true) then return end
end,
do_custom = function(self)
-- Easter egg: Change texture if rabbit is named “Toast”
if self.nametag == "Toast" and not self._has_toast_texture then
self._original_rabbit_texture = self.base_texture
self.base_texture = { "mobs_mc_rabbit_toast.png" }
self.object:set_properties({ textures = self.base_texture })
self._has_toast_texture = true
elseif self.nametag ~= "Toast" and self._has_toast_texture then
self.base_texture = self._original_rabbit_texture
self.object:set_properties({ textures = self.base_texture })
self._has_toast_texture = false
end
end,
} }
mobs:register_mob("mobs_mc:rabbit", rabbit) local sounds = {
random = "mobs_mc_rabbit_random",
damage = "mobs_mc_rabbit_hurt",
death = "mobs_mc_rabbit_death",
attack = "mobs_mc_rabbit_attack",
eat = "mobs_mc_animal_eat_generic",
distance = 16,
}
-- The killer bunny (Only with spawn egg) local biome_list = {
local killer_bunny = table.copy(rabbit)
killer_bunny.description = S("Killer Bunny")
killer_bunny.type = "monster"
killer_bunny.spawn_class = "hostile"
killer_bunny.attack_type = "dogfight"
killer_bunny.specific_attack = { "player", "mobs_mc:wolf", "mobs_mc:dog" }
killer_bunny.damage = 8
killer_bunny.passive = false
-- 8 armor points
killer_bunny.armor = 50
killer_bunny.textures = { "mobs_mc_rabbit_caerbannog.png" }
killer_bunny.view_range = 16
killer_bunny.replace_rate = nil
killer_bunny.replace_what = nil
killer_bunny.on_rightclick = nil
killer_bunny.run_velocity = 6
killer_bunny.do_custom = function(self)
if not self._killer_bunny_nametag_set then
self.nametag = S("The Killer Bunny")
self._killer_bunny_nametag_set = true
end
end
mobs:register_mob("mobs_mc:killer_bunny", killer_bunny)
-- Mob spawning rules.
-- Different skins depending on spawn location <- we'll get to this when the spawning algorithm is fleshed out
mobs:spawn_specific(
"mobs_mc:rabbit",
"overworld",
"ground",
{
"FlowerForest_beach", "FlowerForest_beach",
"Forest_beach", "Forest_beach",
"StoneBeach", "StoneBeach",
@ -161,73 +70,148 @@ mobs:spawn_specific(
"MesaBryce", "MesaBryce",
"JungleEdge", "JungleEdge",
"SavannaM", "SavannaM",
},
9,
minetest.LIGHT_MAX+1,
30,
15000,
8,
mobs_mc.spawn_height.overworld_min,
mobs_mc.spawn_height.overworld_max)
--[[
local spawn = {
name = "mobs_mc:rabbit",
neighbors = {"air"},
chance = 15000,
active_object_count = 10,
min_light = 0,
max_light = minetest.LIGHT_MAX+1,
min_height = mobs_mc.spawn_height.overworld_min,
max_height = mobs_mc.spawn_height.overworld_max,
} }
local spawn_desert = table.copy(spawn) local function spawn_rabbit(pos)
spawn_desert.nodes = mobs_mc.spawn.desert local biome_data = minetest.get_biome_data(pos)
spawn_desert.on_spawn = function(self, pos) local biome_name = biome_data and minetest.get_biome_name(biome_data.biome) or ""
local texture = "mobs_mc_rabbit_gold.png" local mob = minetest.add_entity(pos, mob_name)
self.base_texture = { "mobs_mc_rabbit_gold.png" } local self = mob:get_luaentity()
self.object:set_properties({textures = self.base_texture})
end
mobs:spawn(spawn_desert)
local spawn_snow = table.copy(spawn)
spawn_snow.nodes = mobs_mc.spawn.snow
spawn_snow.on_spawn = function(self, pos)
local texture local texture
local r = math.random(1, 100) if biome_name:find("Desert") then
-- 80% white fur texture = "mobs_mc_rabbit_gold.png"
if r <= 80 then
texture = "mobs_mc_rabbit_white.png"
-- 20% black and white fur
else else
texture = "mobs_mc_rabbit_white_splotched.png" local r = math.random(1, 100)
if biome_name:find("Ice") or biome_name:find("snow") or biome_name:find("Cold") then
-- 80% white fur
if r <= 80 then
texture = "mobs_mc_rabbit_white.png"
-- 20% black and white fur
else
texture = "mobs_mc_rabbit_white_splotched.png"
end
else
-- 50% brown fur
if r <= 50 then
texture = "mobs_mc_rabbit_brown.png"
-- 40% salt fur
elseif r <= 90 then
texture = "mobs_mc_rabbit_salt.png"
-- 10% black fur
else
texture = "mobs_mc_rabbit_black.png"
end
end
end end
self.base_texture = { texture } self.base_texture = {texture}
self.object:set_properties({textures = self.base_texture}) self.object:set_properties({textures = {texture}})
end end
mobs:spawn(spawn_snow)
local spawn_grass = table.copy(spawn) local function do_custom_rabbit(self)
spawn_grass.nodes = mobs_mc.spawn.grassland -- Easter egg: Change texture if rabbit is named “Toast”
spawn_grass.on_spawn = function(self, pos) if self.nametag == "Toast" and not self._has_toast_texture then
local texture self._original_rabbit_texture = self.base_texture
local r = math.random(1, 100) self.base_texture = { "mobs_mc_rabbit_toast.png" }
-- 50% brown fur self.object:set_properties({ textures = self.base_texture })
if r <= 50 then self._has_toast_texture = true
texture = "mobs_mc_rabbit_brown.png" elseif self.nametag ~= "Toast" and self._has_toast_texture then
-- 40% salt fur self.base_texture = self._original_rabbit_texture
elseif r <= 90 then self.object:set_properties({ textures = self.base_texture })
texture = "mobs_mc_rabbit_salt.png" self._has_toast_texture = false
-- 10% black fur
else
texture = "mobs_mc_rabbit_black.png"
end end
self.base_texture = { texture }
self.object:set_properties({textures = self.base_texture})
end end
mobs:spawn(spawn_grass)
]]-- local rabbit = {
description = S("Rabbit"),
type = "animal",
spawn_class = "passive",
passive = true,
reach = 1,
rotate = 270,
hp_min = 3,
hp_max = 3,
xp_min = 1,
xp_max = 3,
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.49, 0.2},
visual = "mesh",
mesh = "mobs_mc_rabbit.b3d",
textures = textures,
visual_size = {x=1.5, y=1.5},
sounds = sounds,
makes_footstep_sound = false,
walk_velocity = 1,
run_velocity = 3.7,
follow_velocity = 1.1,
floats = 1,
runaway = true,
jump = true,
drops = {
{name = mobs_mc.items.rabbit_raw, chance = 1, min = 0, max = 1, looting = "common",},
{name = mobs_mc.items.rabbit_hide, chance = 1, min = 0, max = 1, looting = "common",},
{name = mobs_mc.items.rabbit_foot, chance = 10, min = 0, max = 1, looting = "rare", looting_factor = 0.03,},
},
fear_height = 4,
animation = {
speed_normal = 25, speed_run = 50,
stand_start = 0, stand_end = 0,
walk_start = 0, walk_end = 20,
run_start = 0, run_end = 20,
},
-- Follow (yellow) dangelions, carrots and golden carrots
follow = mobs_mc.follow.rabbit,
view_range = 8,
-- Eat carrots and reduce their growth stage by 1
replace_rate = 10,
replace_what = mobs_mc.replace.rabbit,
on_rightclick = function(self, clicker)
-- Feed, tame protect or capture
if mobs:feed_tame(self, clicker, 1, true, true) then return end
end,
do_custom = do_custom_rabbit,
spawn = spawn_rabbit
}
mobs:register_mob(mob_name, rabbit)
-- The killer bunny (Only with spawn egg)
local killer_bunny = table.copy(rabbit)
killer_bunny.description = S("Killer Bunny")
killer_bunny.type = "monster"
killer_bunny.spawn_class = "hostile"
killer_bunny.attack_type = "dogfight"
killer_bunny.specific_attack = { "player", "mobs_mc:wolf", "mobs_mc:dog" }
killer_bunny.damage = 8
killer_bunny.passive = false
-- 8 armor points
killer_bunny.armor = 50
killer_bunny.textures = { "mobs_mc_rabbit_caerbannog.png" }
killer_bunny.view_range = 16
killer_bunny.replace_rate = nil
killer_bunny.replace_what = nil
killer_bunny.on_rightclick = nil
killer_bunny.run_velocity = 6
killer_bunny.do_custom = function(self)
if not self._killer_bunny_nametag_set then
self.nametag = S("The Killer Bunny")
self._killer_bunny_nametag_set = true
end
end
mobs:register_mob("mobs_mc:killer_bunny", killer_bunny)
-- Mob spawning rules.
-- Different skins depending on spawn location <- we customized spawn function
mobs:spawn_setup({
name = mob_name,
min_light = 9,
chance = 1000,
aoc = 8,
biomes = biome_list,
group_size_max = 1,
baby_min = 1,
baby_max = 2,
})
-- Spawn egg -- Spawn egg
mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0) mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0)

View File

@ -285,7 +285,7 @@ local function initsky(player)
end end
-- MC-style clouds: Layer 127, thickness 4, fly to the “West” -- MC-style clouds: Layer 127, thickness 4, fly to the “West”
player:set_clouds({height=mcl_worlds.layer_to_y(127), speed={x=-2, z=0}, thickness=4, color="#FFF0FEF"}) player:set_clouds(mcl_worlds:get_cloud_parameters() or {height=mcl_worlds.layer_to_y(127), speed={x=-2, z=0}, thickness=4, color="#FFF0FEF"})
end end
minetest.register_on_joinplayer(initsky) minetest.register_on_joinplayer(initsky)

View File

@ -52,7 +52,7 @@ minetest.register_node("mcl_cake:cake", {
fixed = full_cake fixed = full_cake
}, },
stack_max = 1, stack_max = 1,
groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, groups = {handy=1, cake=7, food=2, no_eat_delay=1, compostability=100, attached_node=1, dig_by_piston=1, comparator_signal=14},
drop = "", drop = "",
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
-- Cake is subject to protection -- Cake is subject to protection
@ -125,7 +125,7 @@ local register_slice = function(level, nodebox, desc)
type = "fixed", type = "fixed",
fixed = nodebox, fixed = nodebox,
}, },
groups = {handy=1, cake=level, food=2,no_eat_delay=1,attached_node=1,not_in_creative_inventory=1,dig_by_piston=1,comparator_signal=level*2}, groups = {handy=1, cake=level, food=2, no_eat_delay=1, compostability=100, attached_node=1, not_in_creative_inventory=1, dig_by_piston=1, comparator_signal=level*2},
drop = "", drop = "",
on_rightclick = on_rightclick, on_rightclick = on_rightclick,
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),

View File

@ -32,108 +32,6 @@ minetest.register_craft({
} }
}) })
local compostability = {
["mcl_cake:cake"] = 100,
["mcl_farming:pumpkin_pie"] = 100,
["mcl_farming:potato_item_baked"] = 85,
["mcl_farming:bread"] = 85,
["mcl_farming:cookie"] = 85,
["mcl_farming:hay_block"] = 85,
-- mushroom cap block have 64 variants, wtf!?
["mcl_mushrooms:brown_mushroom_block_cap_111111"] = 85,
["mcl_mushrooms:red_mushroom_block_cap_111111"] = 85,
["mcl_nether:nether_wart_block"] = 85,
["mcl_mushroom:warped_wart_block"] = 85,
["mcl_core:apple"] = 65,
-- missing: azalea
["mcl_farming:beetroot_item"] = 65,
-- missing: big dripleaf
["mcl_farming:carrot_item"] = 65,
-- what's up with cocoa beans?
["mcl_dye:brown"] = 65,
["mcl_flowers:fern"] = 65,
["mcl_flowers:double_fern"] = 65,
["mcl_flowers:allium"] = 65,
["mcl_flowers:azure_bluet"] = 65,
["mcl_flowers:blue_orchid"] = 65,
["mcl_flowers:dandelion"] = 65,
["mcl_flowers:lilac"] = 65,
["mcl_flowers:oxeye_daisy"] = 65,
["mcl_flowers:poppy"] = 65,
["mcl_flowers:tulip_orange"] = 65,
["mcl_flowers:tulip_pink"] = 65,
["mcl_flowers:tulip_red"] = 65,
["mcl_flowers:tulip_white"] = 65,
["mcl_flowers:peony"] = 65,
["mcl_flowers:rose_bush"] = 65,
["mcl_flowers:sunflower"] = 65,
["mcl_flowers:waterlily"] = 65,
["mcl_farming:melon"] = 65,
["mcl_core:moss"] = 65,
-- mushroom aliases below?
["mcl_farming:mushroom_brown"] = 65,
["mcl_mushrooms:mushroom_brown"] = 65,
["mcl_farming:mushroom_red"] = 65,
["mcl_mushrooms:mushroom_red"] = 65,
["mcl_mushrooms:brown_mushroom_block_stem_full"] = 65,
["mcl_mushrooms:red_mushroom_block_stem_full"] = 65,
-- nether wart
["mcl_farming:potato_item"] = 65,
["mcl_farming:pumpkin"] = 65,
["mcl_farming:pumpkin_face_light"] = 65,
["mcl_ocean:sea_pickle_"] = 65,
["mcl_mushroom:shroomlight"] = 65,
-- missing: spore blossom
["mcl_farming:wheat_item"] = 65,
["mcl_mushroom:crimson_fungus"] = 65,
["mcl_mushroom:warped_fungus"] = 65,
["mcl_mushroom:crimson_roots"] = 65,
["mcl_mushroom:warped_roots"] = 65,
["mcl_core:cactus"] = 50,
["mcl_ocean:dried_kelp_block"] = 50,
-- missing: flowering azalea leaves
-- missing: glow lichen
["mcl_farming:melon_item"] = 50,
["mcl_mushroom:nether_sprouts"] = 50,
["mcl_core:reeds"] = 50,
["mcl_flowers:double_grass"] = 50,
["mcl_core:vine"] = 50,
-- missing: weeping vines
["mcl_mushroom:twisting_vines"] = 50,
["mcl_flowers:tallgrass"] = 30,
["mcl_farming:beetroot_seeds"] = 30,
["mcl_core:dirt_with_grass"] = 30,
["mcl_core:tallgrass"] = 30,
["mcl_ocean:dried_kelp"] = 30,
["mcl_ocean:kelp"] = 30,
["mcl_core:leaves"] = 30,
["mcl_core:acacialeaves"] = 30,
["mcl_core:birchleaves"] = 30,
["mcl_core:darkleaves"] = 30,
["mcl_core:jungleleaves"] = 30,
["mcl_core:spruceleaves"] = 30,
--
["mcl_farming:melon_seeds"] = 30,
["mcl_core:moss_carpet"] = 30,
["mcl_farming:pumpkin_seeds"] = 30,
["mcl_core:sapling"] = 30,
["mcl_core:acaciasapling"] = 30,
["mcl_core:birchsapling"] = 30,
["mcl_core:darksapling"] = 30,
["mcl_core:junglesapling"] = 30,
["mcl_core:sprucesapling"] = 30,
["mcl_ocean:seagrass"] = 30,
-- missing: small dripleaf
["mcl_sweet_berry:sweet_berry"] = 30,
["mcl_farming:sweet_berry"] = 30,
["mcl_farming:wheat_seeds"] = 30,
}
local function composter_add_item(pos, node, player, itemstack, pointed_thing) local function composter_add_item(pos, node, player, itemstack, pointed_thing)
-- --
-- handler for filling the composter when rightclicked -- handler for filling the composter when rightclicked
@ -147,8 +45,9 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing)
return itemstack return itemstack
end end
local itemname = itemstack:get_name() local itemname = itemstack:get_name()
local chance = compostability[itemname] local chance = minetest.get_item_group(itemname, "compostability")
if chance then
if chance > 0 then
if not minetest.is_creative_enabled(player:get_player_name()) then if not minetest.is_creative_enabled(player:get_player_name()) then
itemstack:take_item() itemstack:take_item()
end end

View File

@ -139,7 +139,7 @@ minetest.register_craftitem("mcl_core:apple", {
stack_max = 64, stack_max = 64,
on_place = minetest.item_eat(4), on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4), on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4 }, groups = { food = 2, eatable = 4, compostability=65 },
_mcl_saturation = 2.4, _mcl_saturation = 2.4,
}) })

View File

@ -369,7 +369,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
color = "#8EB971", color = "#8EB971",
is_ground_content = true, is_ground_content = true,
stack_max = 64, stack_max = 64,
groups = {handy=1,shovely=1,dirt=2,grass_block=1, grass_block_no_snow=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, enderman_takable=1, building_block=1}, groups = {handy=1,shovely=1,dirt=2,grass_block=1, grass_block_no_snow=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, enderman_takable=1, building_block=1, compostability=30},
drop = "mcl_core:dirt", drop = "mcl_core:dirt",
sounds = mcl_sounds.node_sound_dirt_defaults({ sounds = mcl_sounds.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.1}, footstep = {name="default_grass_footstep", gain=0.1},
@ -473,7 +473,7 @@ minetest.register_node("mcl_core:moss", {
tiles = {"mcl_core_moss_block.png"}, tiles = {"mcl_core_moss_block.png"},
is_ground_content = true, is_ground_content = true,
stack_max = 64, stack_max = 64,
groups = {handy=1, hoey=1}, groups = {handy=1, hoey=1, compostability=65},
--sounds = TODO: add sound --sounds = TODO: add sound
_mcl_blast_resistance = 0.1, _mcl_blast_resistance = 0.1,
_mcl_hardness = 0.1, _mcl_hardness = 0.1,
@ -1096,7 +1096,7 @@ minetest.register_node("mcl_core:moss", {
tiles = {"mcl_core_moss_block.png"}, tiles = {"mcl_core_moss_block.png"},
is_ground_content = true, is_ground_content = true,
stack_max = 64, stack_max = 64,
groups = {handy=1, hoey=1}, groups = {handy=1, hoey=1, compostability=65},
--sounds = TODO: add sound --sounds = TODO: add sound
_mcl_blast_resistance = 0.1, _mcl_blast_resistance = 0.1,
_mcl_hardness = 0.1, _mcl_hardness = 0.1,
@ -1153,7 +1153,7 @@ minetest.register_node("mcl_core:moss_carpet", {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}, {-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
}, },
}, },
groups = {handy=1, hoey=1}, groups = {handy=1, hoey=1, compostability=30},
--sounds = TODO: add sound --sounds = TODO: add sound
_mcl_blast_resistance = 0.1, _mcl_blast_resistance = 0.1,
_mcl_hardness = 0.1, _mcl_hardness = 0.1,

View File

@ -12,7 +12,7 @@ minetest.register_node("mcl_core:cactus", {
tiles = {"mcl_core_cactus_top.png", "mcl_core_cactus_bottom.png", "mcl_core_cactus_side.png"}, tiles = {"mcl_core_cactus_top.png", "mcl_core_cactus_bottom.png", "mcl_core_cactus_side.png"},
is_ground_content = true, is_ground_content = true,
stack_max = 64, stack_max = 64,
groups = {handy=1, attached_node=1, plant=1, deco_block=1, dig_by_piston=1, enderman_takable=1}, groups = {handy=1, attached_node=1, plant=1, deco_block=1, dig_by_piston=1, enderman_takable=1, compostability=50},
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
@ -79,7 +79,7 @@ minetest.register_node("mcl_core:reeds", {
}, },
}, },
stack_max = 64, stack_max = 64,
groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1}, groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1, compostability=50},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "", node_placement_prediction = "",
drop = "mcl_core:reeds", -- to prevent color inheritation drop = "mcl_core:reeds", -- to prevent color inheritation

View File

@ -104,7 +104,7 @@ minetest.register_node("mcl_core:vine", {
type = "wallmounted", type = "wallmounted",
}, },
stack_max = 64, stack_max = 64,
groups = {handy=1,axey=1,shearsy=1,swordy=1, flammable=2,deco_block=1,destroy_by_lava_flow=1,dig_by_piston=1, fire_encouragement=15, fire_flammability=100}, groups = {handy=1,axey=1,shearsy=1,swordy=1, flammable=2,deco_block=1,destroy_by_lava_flow=1,dig_by_piston=1, fire_encouragement=15, fire_flammability=100, compostability=50},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
drop = "", drop = "",
_mcl_shears_drop = true, _mcl_shears_drop = true,

View File

@ -162,7 +162,8 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d
deco_block=1, deco_block=1,
dig_by_piston=1, dig_by_piston=1,
fire_encouragement=30, fire_encouragement=30,
fire_flammability=60 fire_flammability=60,
compostability=30
}, },
drop = get_drops(0), drop = get_drops(0),
_mcl_shears_drop = true, _mcl_shears_drop = true,
@ -194,7 +195,7 @@ local function register_sapling(subname, description, longdesc, tt_help, texture
fixed = selbox fixed = selbox
}, },
stack_max = 64, stack_max = 64,
groups = {dig_immediate=3, plant=1,sapling=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1}, groups = {dig_immediate=3, plant=1,sapling=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1, compostability=30},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)

View File

@ -78,7 +78,7 @@ dyelocal.dyes = {
{"dark_green", "dye_dark_green", S("Cactus Green"),{dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}}, {"dark_green", "dye_dark_green", S("Cactus Green"),{dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
{"green", "mcl_dye_lime", S("Lime Dye"), {dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_green=1}}, {"green", "mcl_dye_lime", S("Lime Dye"), {dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
{"yellow", "dye_yellow", S("Dandelion Yellow"), {dye=1, craftitem=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}}, {"yellow", "dye_yellow", S("Dandelion Yellow"), {dye=1, craftitem=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
{"brown", "mcl_dye_brown", S("Cocoa Beans"), {dye=1, craftitem=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}}, {"brown", "mcl_dye_brown", S("Cocoa Beans"), {dye=1, craftitem=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1, compostability=65}},
{"orange", "dye_orange", S("Orange Dye"), {dye=1, craftitem=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}}, {"orange", "dye_orange", S("Orange Dye"), {dye=1, craftitem=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
{"red", "dye_red", S("Rose Red"), {dye=1, craftitem=1, basecolor_red=1, excolor_red=1, unicolor_red=1}}, {"red", "dye_red", S("Rose Red"), {dye=1, craftitem=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
{"magenta", "dye_magenta", S("Magenta Dye"), {dye=1, craftitem=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}}, {"magenta", "dye_magenta", S("Magenta Dye"), {dye=1, craftitem=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},

View File

@ -5,7 +5,7 @@ minetest.register_craftitem("mcl_farming:beetroot_seeds", {
_tt_help = S("Grows on farmland"), _tt_help = S("Grows on farmland"),
_doc_items_longdesc = S("Grows into a beetroot plant. Chickens like beetroot seeds."), _doc_items_longdesc = S("Grows into a beetroot plant. Chickens like beetroot seeds."),
_doc_items_usagehelp = S("Place the beetroot seeds on farmland (which can be created with a hoe) to plant a beetroot plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it beetroot seeds."), _doc_items_usagehelp = S("Place the beetroot seeds on farmland (which can be created with a hoe) to plant a beetroot plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it beetroot seeds."),
groups = { craftitem=1 }, groups = { craftitem=1, compostability=30 },
inventory_image = "mcl_farming_beetroot_seeds.png", inventory_image = "mcl_farming_beetroot_seeds.png",
wield_image = "mcl_farming_beetroot_seeds.png", wield_image = "mcl_farming_beetroot_seeds.png",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
@ -133,7 +133,7 @@ minetest.register_craftitem("mcl_farming:beetroot_item", {
wield_image = "mcl_farming_beetroot.png", wield_image = "mcl_farming_beetroot.png",
on_place = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1, compostability=65 },
_mcl_saturation = 1.2, _mcl_saturation = 1.2,
}) })

View File

@ -86,7 +86,7 @@ minetest.register_craftitem("mcl_farming:carrot_item", {
_doc_items_longdesc = S("Carrots can be eaten and planted. Pigs and rabbits like carrots."), _doc_items_longdesc = S("Carrots can be eaten and planted. Pigs and rabbits like carrots."),
_doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant the carrot. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."), _doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant the carrot. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."),
inventory_image = "farming_carrot.png", inventory_image = "farming_carrot.png",
groups = { food = 2, eatable = 3 }, groups = { food = 2, eatable = 3, compostability=65 },
_mcl_saturation = 3.6, _mcl_saturation = 3.6,
on_secondary_use = minetest.item_eat(3), on_secondary_use = minetest.item_eat(3),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)

View File

@ -7,7 +7,7 @@ minetest.register_craftitem("mcl_farming:melon_seeds", {
_doc_items_longdesc = S("Grows into a melon stem which in turn grows melons. Chickens like melon seeds."), _doc_items_longdesc = S("Grows into a melon stem which in turn grows melons. Chickens like melon seeds."),
_doc_items_usagehelp = S("Place the melon seeds on farmland (which can be created with a hoe) to plant a melon stem. Melon stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem will attempt to grow a melon at the side. Rightclick an animal to feed it melon seeds."), _doc_items_usagehelp = S("Place the melon seeds on farmland (which can be created with a hoe) to plant a melon stem. Melon stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem will attempt to grow a melon at the side. Rightclick an animal to feed it melon seeds."),
stack_max = 64, stack_max = 64,
groups = { craftitem=1 }, groups = { craftitem=1, compostability=30 },
inventory_image = "mcl_farming_melon_seeds.png", inventory_image = "mcl_farming_melon_seeds.png",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:melontige_1") return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:melontige_1")
@ -21,7 +21,7 @@ local melon_base_def = {
_doc_items_longdesc = S("A melon is a block which can be grown from melon stems, which in turn are grown from melon seeds. It can be harvested for melon slices."), _doc_items_longdesc = S("A melon is a block which can be grown from melon stems, which in turn are grown from melon seeds. It can be harvested for melon slices."),
stack_max = 64, stack_max = 64,
tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png"}, tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png"},
groups = {handy=1,axey=1, plant=1,building_block=1,enderman_takable=1,dig_by_piston=1}, groups = {handy=1,axey=1, plant=1,building_block=1,enderman_takable=1,dig_by_piston=1, compostability=65},
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
@ -134,7 +134,7 @@ minetest.register_craftitem("mcl_farming:melon_item", {
inventory_image = "farming_melon.png", inventory_image = "farming_melon.png",
on_place = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2), on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2, compostability=50 },
_mcl_saturation = 1.2, _mcl_saturation = 1.2,
}) })

View File

@ -91,7 +91,7 @@ minetest.register_craftitem("mcl_farming:potato_item", {
_doc_items_longdesc = S("Potatoes are food items which can be eaten, cooked in the furnace and planted. Pigs like potatoes."), _doc_items_longdesc = S("Potatoes are food items which can be eaten, cooked in the furnace and planted. Pigs like potatoes."),
_doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant it. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."), _doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant it. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."),
inventory_image = "farming_potato.png", inventory_image = "farming_potato.png",
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1, compostability=65 },
_mcl_saturation = 0.6, _mcl_saturation = 0.6,
stack_max = 64, stack_max = 64,
on_secondary_use = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1),
@ -112,7 +112,7 @@ minetest.register_craftitem("mcl_farming:potato_item_baked", {
inventory_image = "farming_potato_baked.png", inventory_image = "farming_potato_baked.png",
on_place = minetest.item_eat(5), on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5), on_secondary_use = minetest.item_eat(5),
groups = { food = 2, eatable = 5 }, groups = { food = 2, eatable = 5, compostability = 85 },
_mcl_saturation = 6.0, _mcl_saturation = 6.0,
}) })

View File

@ -15,7 +15,7 @@ minetest.register_craftitem("mcl_farming:pumpkin_seeds", {
_doc_items_usagehelp = S("Place the pumpkin seeds on farmland (which can be created with a hoe) to plant a pumpkin stem. Pumpkin stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem attempts to grow a pumpkin next to it. Rightclick an animal to feed it pumpkin seeds."), _doc_items_usagehelp = S("Place the pumpkin seeds on farmland (which can be created with a hoe) to plant a pumpkin stem. Pumpkin stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem attempts to grow a pumpkin next to it. Rightclick an animal to feed it pumpkin seeds."),
stack_max = 64, stack_max = 64,
inventory_image = "mcl_farming_pumpkin_seeds.png", inventory_image = "mcl_farming_pumpkin_seeds.png",
groups = { craftitem=1 }, groups = { craftitem=1, compostability=30 },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:pumpkin_1") return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:pumpkin_1")
end end
@ -99,7 +99,7 @@ local pumpkin_base_def = {
stack_max = 64, stack_max = 64,
paramtype2 = "facedir", paramtype2 = "facedir",
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png"}, 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}, groups = {handy=1,axey=1, plant=1,building_block=1, dig_by_piston=1, enderman_takable=1, compostability=65},
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
on_rotate = on_rotate, on_rotate = on_rotate,
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
@ -192,7 +192,7 @@ minetest.register_node("mcl_farming:pumpkin_face_light", {
paramtype2 = "facedir", paramtype2 = "facedir",
light_source = minetest.LIGHT_MAX, light_source = minetest.LIGHT_MAX,
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"}, tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"},
groups = {handy=1,axey=1, building_block=1, dig_by_piston=1 }, groups = {handy=1,axey=1, building_block=1, dig_by_piston=1, compostability=65 },
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
-- Attempt to spawn iron golem or snow golem -- Attempt to spawn iron golem or snow golem
@ -230,7 +230,7 @@ minetest.register_craftitem("mcl_farming:pumpkin_pie", {
wield_image = "mcl_farming_pumpkin_pie.png", wield_image = "mcl_farming_pumpkin_pie.png",
on_place = minetest.item_eat(8), on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8), on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 }, groups = { food = 2, eatable = 8, compostability=100 },
_mcl_saturation = 4.8, _mcl_saturation = 4.8,
}) })

View File

@ -31,7 +31,7 @@ minetest.register_craftitem("mcl_farming:sweet_berry", {
inventory_image = "mcl_farming_sweet_berry.png", inventory_image = "mcl_farming_sweet_berry.png",
_mcl_saturation = 0.2, _mcl_saturation = 0.2,
stack_max = 64, stack_max = 64,
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1, compostability=30 },
on_secondary_use = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_sweet_berry:sweet_berry_bush_0") local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_sweet_berry:sweet_berry_bush_0")

View File

@ -9,7 +9,7 @@ minetest.register_craftitem("mcl_farming:wheat_seeds", {
Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant.
They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds.
]]), ]]),
groups = { craftitem=1 }, groups = { craftitem=1, compostability=30 },
inventory_image = "mcl_farming_wheat_seeds.png", inventory_image = "mcl_farming_wheat_seeds.png",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:wheat_1") return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:wheat_1")
@ -104,7 +104,7 @@ minetest.register_craftitem("mcl_farming:wheat_item", {
_doc_items_longdesc = S("Wheat is used in crafting. Some animals like wheat."), _doc_items_longdesc = S("Wheat is used in crafting. Some animals like wheat."),
_doc_items_usagehelp = S("Use the “Place” key on an animal to try to feed it wheat."), _doc_items_usagehelp = S("Use the “Place” key on an animal to try to feed it wheat."),
inventory_image = "farming_wheat_harvested.png", inventory_image = "farming_wheat_harvested.png",
groups = { craftitem = 1 }, groups = { craftitem = 1, compostability=65 },
}) })
minetest.register_craft({ minetest.register_craft({
@ -125,7 +125,7 @@ minetest.register_craftitem("mcl_farming:cookie", {
description = S("Cookie"), description = S("Cookie"),
_doc_items_longdesc = S("This is a food item which can be eaten."), _doc_items_longdesc = S("This is a food item which can be eaten."),
inventory_image = "farming_cookie.png", inventory_image = "farming_cookie.png",
groups = {food=2, eatable=2}, groups = {food=2, eatable=2, compostability=85},
_mcl_saturation = 0.4, _mcl_saturation = 0.4,
on_place = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2), on_secondary_use = minetest.item_eat(2),
@ -136,7 +136,7 @@ minetest.register_craftitem("mcl_farming:bread", {
description = S("Bread"), description = S("Bread"),
_doc_items_longdesc = S("This is a food item which can be eaten."), _doc_items_longdesc = S("This is a food item which can be eaten."),
inventory_image = "farming_bread.png", inventory_image = "farming_bread.png",
groups = {food=2, eatable=5}, groups = {food=2, eatable=5, compostability=85},
_mcl_saturation = 6.0, _mcl_saturation = 6.0,
on_place = minetest.item_eat(5), on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5), on_secondary_use = minetest.item_eat(5),
@ -156,8 +156,7 @@ minetest.register_node("mcl_farming:hay_block", {
stack_max = 64, stack_max = 64,
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = mcl_util.rotate_axis, on_place = mcl_util.rotate_axis,
groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, groups = {handy=1, hoey=1, compostability=85, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80},
fire_flammability=20, building_block=1, fall_damage_add_percent=-80},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_rotate = on_rotate, on_rotate = on_rotate,
_mcl_blast_resistance = 0.5, _mcl_blast_resistance = 0.5,

View File

@ -80,7 +80,7 @@ function mcl_flowers.register_simple_flower(name, def)
walkable = false, walkable = false,
stack_max = 64, stack_max = 64,
drop = def.drop, drop = def.drop,
groups = {dig_immediate=3,flammable=2,fire_encouragement=60,fire_flammability=100,plant=1,flower=1,place_flowerlike=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, groups = {dig_immediate=3,flammable=2,fire_encouragement=60,fire_flammability=100,plant=1,flower=1,place_flowerlike=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, compostability=65},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "", node_placement_prediction = "",
on_place = on_place_flower, on_place = on_place_flower,
@ -143,7 +143,7 @@ local def_tallgrass = {
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
is_ground_content = true, is_ground_content = true,
groups = {handy=1,shearsy=1, flammable=3,fire_encouragement=60,fire_flammability=100,attached_node=1,plant=1,place_flowerlike=2,non_mycelium_plant=1,dig_by_water=1,destroy_by_lava_flow=1,deco_block=1}, groups = {handy=1,shearsy=1, flammable=3,fire_encouragement=60,fire_flammability=100,attached_node=1,plant=1,place_flowerlike=2,non_mycelium_plant=1,dig_by_water=1,destroy_by_lava_flow=1,deco_block=1, compostability=30},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
drop = wheat_seed_drop, drop = wheat_seed_drop,
_mcl_shears_drop = true, _mcl_shears_drop = true,
@ -163,6 +163,7 @@ def_fern._doc_items_longdesc = S("Ferns are small plants which occur naturally i
def_fern.tiles = { "mcl_flowers_fern.png" } def_fern.tiles = { "mcl_flowers_fern.png" }
def_fern.inventory_image = "mcl_flowers_fern_inv.png" def_fern.inventory_image = "mcl_flowers_fern_inv.png"
def_fern.wield_image = "mcl_flowers_fern_inv.png" def_fern.wield_image = "mcl_flowers_fern_inv.png"
def_fern.groups.compostability=65
def_fern.selection_box = { def_fern.selection_box = {
type = "fixed", type = "fixed",
fixed = { -6/16, -0.5, -6/16, 6/16, 5/16, 6/16 }, fixed = { -6/16, -0.5, -6/16, 6/16, 5/16, 6/16 },
@ -205,6 +206,13 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
bottom_groups.not_in_creative_inventory = 1 bottom_groups.not_in_creative_inventory = 1
create_entry = false create_entry = false
end end
-- some special cases for the composter group
if name == "double_fern" or "peony" or "rose_bush" or "lilac" or "sunflower" then
bottom_groups.compostability = 65
end
if name == "double_grass" then
bottom_groups.compostability = 50
end
-- Drop itself by default -- Drop itself by default
local drop_bottom, drop_top local drop_bottom, drop_top
if not drop then if not drop then
@ -410,7 +418,7 @@ minetest.register_node("mcl_flowers:waterlily", {
liquids_pointable = true, liquids_pointable = true,
walkable = true, walkable = true,
sunlight_propagates = true, sunlight_propagates = true,
groups = {dig_immediate = 3, plant=1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, deco_block=1, dig_by_boat=1}, groups = {dig_immediate = 3, plant=1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, deco_block=1, dig_by_boat=1, compostability=65},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "", node_placement_prediction = "",
node_box = { node_box = {

View File

@ -32,7 +32,7 @@ minetest.register_node("mcl_mushroom:warped_fungus", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1}, groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, compostability=65},
light_source = 1, light_source = 1,
selection_box = { selection_box = {
@ -67,7 +67,7 @@ minetest.register_node("mcl_mushroom:twisting_vines", {
walkable = false, walkable = false,
climbable = true, climbable = true,
buildable_to = true, buildable_to = true,
groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1}, groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1, compostability=50},
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -3/16, -0.5, -3/16, 3/16, 0.5, 3/16 }, fixed = { -3/16, -0.5, -3/16, 3/16, 0.5, 3/16 },
@ -108,7 +108,7 @@ minetest.register_node("mcl_mushroom:nether_sprouts", {
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1}, groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1, compostability=50},
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -4/16, -0.5, -4/16, 4/16, 0, 4/16 }, fixed = { -4/16, -0.5, -4/16, 4/16, 0, 4/16 },
@ -130,7 +130,7 @@ minetest.register_node("mcl_mushroom:warped_roots", {
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1}, groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1, compostability=65},
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -6/16, -0.5, -6/16, 6/16, -4/16, 6/16 }, fixed = { -6/16, -0.5, -6/16, 6/16, -4/16, 6/16 },
@ -144,7 +144,7 @@ minetest.register_node("mcl_mushroom:warped_roots", {
minetest.register_node("mcl_mushroom:warped_wart_block", { minetest.register_node("mcl_mushroom:warped_wart_block", {
description = S("Warped Wart Block"), description = S("Warped Wart Block"),
tiles = {"warped_wart_block.png"}, tiles = {"warped_wart_block.png"},
groups = {handy=1,hoe=7,swordy=1, deco_block=1, }, groups = {handy=1,hoe=7,swordy=1, compostability=85, deco_block=1, },
stack_max = 64, stack_max = 64,
_mcl_hardness = 2, _mcl_hardness = 2,
}) })
@ -152,7 +152,7 @@ minetest.register_node("mcl_mushroom:warped_wart_block", {
minetest.register_node("mcl_mushroom:shroomlight", { minetest.register_node("mcl_mushroom:shroomlight", {
description = S("Shroomlight"), description = S("Shroomlight"),
tiles = {"shroomlight.png"}, tiles = {"shroomlight.png"},
groups = {handy=1,hoe=7,swordy=1, leaves=1, deco_block=1, }, groups = {handy=1,hoe=7,swordy=1, leaves=1, deco_block=1, compostability=65, },
stack_max = 64, stack_max = 64,
_mcl_hardness = 2, _mcl_hardness = 2,
-- this is 15 in Minecraft -- this is 15 in Minecraft
@ -305,7 +305,7 @@ minetest.register_node("mcl_mushroom:crimson_fungus", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, compostability=65},
light_source = 1, light_source = 1,
selection_box = { selection_box = {
@ -339,7 +339,7 @@ minetest.register_node("mcl_mushroom:crimson_roots", {
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1}, groups = {dig_immediate=3,vines=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,deco_block=1, shearsy = 1, compostability=65},
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -6/16, -0.5, -6/16, 6/16, -4/16, 6/16 }, fixed = { -6/16, -0.5, -6/16, 6/16, -4/16, 6/16 },

View File

@ -3,7 +3,7 @@ local S = minetest.get_translator(minetest.get_current_modname())
local vector = vector local vector = vector
local template = { local template = {
groups = {handy=1,axey=1, building_block = 1, material_wood = 1, flammable = -1 }, groups = {handy=1,axey=1, building_block = 1, material_wood = 1, flammable = -1, compostability=85 },
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
is_ground_content = true, is_ground_content = true,
_mcl_blast_resistance = 0.2, _mcl_blast_resistance = 0.2,
@ -51,6 +51,7 @@ local function register_mushroom(color, species_id, template, d_cap, d_stem, d_s
stem_full.tiles = { "mcl_mushrooms_mushroom_block_skin_stem.png" } stem_full.tiles = { "mcl_mushrooms_mushroom_block_skin_stem.png" }
stem_full.groups.huge_mushroom = species_id stem_full.groups.huge_mushroom = species_id
stem_full.groups.huge_mushroom_stem = 2 stem_full.groups.huge_mushroom_stem = 2
stem_full.groups.compostability=65
minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem_full", stem_full) minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem_full", stem_full)
-- Stem -- Stem
@ -60,6 +61,7 @@ local function register_mushroom(color, species_id, template, d_cap, d_stem, d_s
stem.tiles = { "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_skin_stem.png" } stem.tiles = { "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_skin_stem.png" }
stem.groups.huge_mushroom = species_id stem.groups.huge_mushroom = species_id
stem.groups.huge_mushroom_stem = 1 stem.groups.huge_mushroom_stem = 1
stem.groups.compostability=65
minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem", stem) minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem", stem)
-- Mushroom block (cap) -- Mushroom block (cap)

View File

@ -38,7 +38,7 @@ minetest.register_node("mcl_mushrooms:mushroom_brown", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, compostability=65},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
light_source = 1, light_source = 1,
selection_box = { selection_box = {
@ -62,7 +62,7 @@ minetest.register_node("mcl_mushrooms:mushroom_red", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, compostability=65},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",

View File

@ -202,7 +202,7 @@ minetest.register_node("mcl_nether:nether_wart_block", {
stack_max = 64, stack_max = 64,
tiles = {"mcl_nether_nether_wart_block.png"}, tiles = {"mcl_nether_nether_wart_block.png"},
is_ground_content = false, is_ground_content = false,
groups = {handy=1, hoey=1, building_block=1}, groups = {handy=1, hoey=1, building_block=1, compostability=85},
sounds = mcl_sounds.node_sound_leaves_defaults( sounds = mcl_sounds.node_sound_leaves_defaults(
{ {
footstep={name="default_dirt_footstep", gain=0.7}, footstep={name="default_dirt_footstep", gain=0.7},

View File

@ -150,7 +150,7 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", {
end end
end end
end, end,
groups = { craftitem = 1, brewitem=1 }, groups = { craftitem = 1, brewitem=1, compostability=30 },
}) })
local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"} local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"}

View File

@ -741,7 +741,7 @@ minetest.register_craftitem("mcl_ocean:kelp", {
inventory_image = "mcl_ocean_kelp_item.png", inventory_image = "mcl_ocean_kelp_item.png",
wield_image = "mcl_ocean_kelp_item.png", wield_image = "mcl_ocean_kelp_item.png",
on_place = kelp.kelp_on_place, on_place = kelp.kelp_on_place,
groups = { deco_block = 1 }, groups = { deco_block = 1, compostability=30 },
}) })
if mod_doc then if mod_doc then
@ -756,7 +756,7 @@ minetest.register_craftitem("mcl_ocean:dried_kelp", {
_doc_items_longdesc = S("Dried kelp is a food item."), _doc_items_longdesc = S("Dried kelp is a food item."),
inventory_image = "mcl_ocean_dried_kelp.png", inventory_image = "mcl_ocean_dried_kelp.png",
wield_image = "mcl_ocean_dried_kelp.png", wield_image = "mcl_ocean_dried_kelp.png",
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1, compostability=30 },
on_place = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1),
_mcl_saturation = 0.6, _mcl_saturation = 0.6,
@ -773,7 +773,7 @@ minetest.register_node("mcl_ocean:dried_kelp_block", {
description = S("Dried Kelp Block"), description = S("Dried Kelp Block"),
_doc_items_longdesc = S("A decorative block that serves as a great furnace fuel."), _doc_items_longdesc = S("A decorative block that serves as a great furnace fuel."),
tiles = { "mcl_ocean_dried_kelp_top.png", "mcl_ocean_dried_kelp_bottom.png", "mcl_ocean_dried_kelp_side.png" }, tiles = { "mcl_ocean_dried_kelp_top.png", "mcl_ocean_dried_kelp_bottom.png", "mcl_ocean_dried_kelp_side.png" },
groups = { handy = 1, hoey = 1, building_block = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60 }, groups = { handy = 1, hoey = 1, building_block = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60, compostability=50 },
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = mcl_util.rotate_axis, on_place = mcl_util.rotate_axis,

View File

@ -106,7 +106,7 @@ for s=1,4 do
}, },
inventory_image = img, inventory_image = img,
wield_image = img, wield_image = img,
groups = { dig_immediate = 3, deco_block = 1, sea_pickle=1, not_in_creative_inventory=nici }, groups = { dig_immediate = 3, deco_block = 1, sea_pickle=1, not_in_creative_inventory=nici, compostability=65 },
-- Light level: 6 at size 1, +3 for each additional stage -- Light level: 6 at size 1, +3 for each additional stage
light_source = math.min(6 + (s-1)*3, minetest.LIGHT_MAX), light_source = math.min(6 + (s-1)*3, minetest.LIGHT_MAX),
selection_box = { selection_box = {

View File

@ -85,7 +85,7 @@ minetest.register_craftitem("mcl_ocean:seagrass", {
inventory_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", inventory_image = "mcl_ocean_seagrass.png^[verticalframe:12:0",
wield_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", wield_image = "mcl_ocean_seagrass.png^[verticalframe:12:0",
on_place = seagrass_on_place, on_place = seagrass_on_place,
groups = { deco_block = 1 }, groups = { deco_block = 1, compostability=30 },
}) })
-- Seagrass nodes: seagrass on a surface node -- Seagrass nodes: seagrass on a surface node

View File

@ -22,6 +22,10 @@ local OCEAN_MIN = -15
local DEEP_OCEAN_MAX = OCEAN_MIN - 1 local DEEP_OCEAN_MAX = OCEAN_MIN - 1
local DEEP_OCEAN_MIN = -31 local DEEP_OCEAN_MIN = -31
local minetest_get_perlin = minetest.get_perlin
local math_floor = math.floor
local math_abs = math.abs
--[[ Special biome field: _mcl_biome_type: --[[ Special biome field: _mcl_biome_type:
Rough categorization of biomes: One of "snowy", "cold", "medium" and "hot" Rough categorization of biomes: One of "snowy", "cold", "medium" and "hot"
Based off <https://minecraft.gamepedia.com/Biomes> ]] Based off <https://minecraft.gamepedia.com/Biomes> ]]
@ -3922,6 +3926,16 @@ local function register_decorations()
end end
-- Decorations in non-Overworld dimensions -- Decorations in non-Overworld dimensions
local chorus_noise_params = {
offset = -0.012,
scale = 0.024,
spread = {x = 100, y = 100, z = 100},
seed = 257,
octaves = 3,
persistence = 0.6,
}
local function register_dimension_decorations() local function register_dimension_decorations()
--[[ NETHER ]] --[[ NETHER ]]
-- TODO: Nether -- TODO: Nether
@ -3935,14 +3949,7 @@ local function register_dimension_decorations()
place_on = {"mcl_end:end_stone", "air"}, place_on = {"mcl_end:end_stone", "air"},
flags = "all_floors", flags = "all_floors",
sidelen = 16, sidelen = 16,
noise_params = { noise_params = chorus_noise_params,
offset = -0.012,
scale = 0.024,
spread = {x = 100, y = 100, z = 100},
seed = 257,
octaves = 3,
persist = 0.6
},
y_min = mcl_mapgen.end_.min, y_min = mcl_mapgen.end_.min,
y_max = mcl_mapgen.end_.max, y_max = mcl_mapgen.end_.max,
decoration = "mcl_end:chorus_flower", decoration = "mcl_end:chorus_flower",
@ -3962,6 +3969,8 @@ end
-- Detect mapgen to select functions -- Detect mapgen to select functions
-- --
local chorus_perlin_noise
if not mcl_mapgen.singlenode then if not mcl_mapgen.singlenode then
if not superflat then if not superflat then
if not mcl_mapgen.v6 then if not mcl_mapgen.v6 then
@ -3994,8 +4003,10 @@ if not mcl_mapgen.singlenode then
vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify") vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify")
local gennotify = vm_context.gennotify local gennotify = vm_context.gennotify
for _, pos in pairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do for _, pos in pairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do
chorus_perlin_noise = chorus_perlin_noise or minetest_get_perlin(chorus_noise_params)
local realpos = { x = pos.x, y = pos.y + 1, z = pos.z } local realpos = { x = pos.x, y = pos.y + 1, z = pos.z }
local pr = PseudoRandom(vm_context.blockseed) local noise = chorus_perlin_noise:get_3d(realpos)
local pr = PseudoRandom(math_floor(math_abs(noise * 32767)) % 32768)
minetest.after(1, mcl_end.grow_chorus_plant, realpos, false, pr) minetest.after(1, mcl_end.grow_chorus_plant, realpos, false, pr)
end end
return vm_context return vm_context
@ -4003,4 +4014,3 @@ if not mcl_mapgen.singlenode then
end end
end end

View File

@ -3,13 +3,41 @@ local S = minetest.get_translator(minetest.get_current_modname())
local orig_func = minetest.registered_chatcommands["spawnentity"].func local orig_func = minetest.registered_chatcommands["spawnentity"].func
local cmd = table.copy(minetest.registered_chatcommands["spawnentity"]) local cmd = table.copy(minetest.registered_chatcommands["spawnentity"])
cmd.func = function(name, param) cmd.func = function(name, param)
local ent = minetest.registered_entities[param] local params = param:split(" ")
if minetest.settings:get_bool("only_peaceful_mobs", false) and ent and ent._cmi_is_mob and ent.type == "monster" then if not params[1] or params[3] then
return false, S("Only peaceful mobs allowed!") return false, S("Usage: /spawnentity <EntityName> [<X>,<Y>,<Z>]")
else
local bool, msg = orig_func(name, param)
return bool, msg
end end
local entity_name = params[1]
local pos = params[2]
local entity_def = minetest.registered_entities[entity_name]
if not entity_def then
entity_name = "mobs_mc:" .. entity_name
entity_def = minetest.registered_entities[entity_name]
if not entity_def then
return false, S("Error: Unknown entity name")
end
end
if entity_def._cmi_is_mob then
if minetest.settings:get_bool("only_peaceful_mobs", false) and entity_def.type == "monster" then
return false, S("Only peaceful mobs allowed!")
end
mobs.spawn_mob(
entity_name,
pos
and minetest.string_to_pos(pos)
or vector.add(
minetest.get_player_by_name(name):get_pos(),
{
x = math.random()-0.5,
y = math.random(),
z = math.random()-0.5
}
)
)
return true, S("Mob @1 spawned", entity_name)
end
local bool, msg = orig_func(name, param)
return bool, msg
end end
minetest.unregister_chatcommand("spawnentity") minetest.unregister_chatcommand("spawnentity")
minetest.register_chatcommand("summon", cmd) minetest.register_chatcommand("summon", cmd)

View File

@ -0,0 +1,112 @@
local ban_spammers = true
local kick_spammers = true
local revoke_shout_for_spammers = true
local limit_messages = 10
local limit_message_length = 200
local block_special_chars = true
local enable_antispam = ban_spammers or kick_spammers or revoke_shout_for_spammers
local function update_settings()
ban_spammers = minetest.settings:get_bool("ban_spammers", true)
kick_spammers = minetest.settings:get_bool("kick_spammers", true)
revoke_shout_for_spammers = minetest.settings:get_bool("revoke_shout_for_spammers", true)
limit_messages = tonumber(minetest.settings:get("limit_messages") or 10)
limit_message_length = tonumber(minetest.settings:get("limit_message_length") or 200)
block_special_chars = minetest.settings:get_bool("block_special_chars", true)
enable_antispam = ban_spammers or kick_spammers or revoke_shout_for_spammers
minetest.after(7, update_settings)
end
update_settings()
local last_messages = {}
local exceeders = {}
local special_users = {}
local function ban(name)
if revoke_shout_for_spammers then
local privs = minetest.get_player_privs(name)
if privs then
privs.shout = nil
minetest.set_player_privs(name, privs)
end
end
if ban_spammers then
minetest.ban_player(name)
elseif kick_spammers then
minetest.kick_player(name)
end
end
local last_char = string.char(127)
local function on_chat_message(name, message)
if not enable_antispam then return end
local length = message:len()
if last_messages.job then
last_messages.job:cancel()
last_messages.job = nil
end
if last_messages.name and last_messages.name == name then
last_messages.count = last_messages.count + 1
last_messages.summary_length = last_messages.summary_length + length
if last_messages.count >= limit_messages then
ban(name)
end
else
last_messages.name = name
last_messages.count = 1
last_messages.summary_length = length
end
last_messages.job = minetest.after(300, function()
last_messages.name = nil
last_messages.job = nil
end)
if limit_message_length > 0 and message:len() > limit_message_length then
if exceeders[name] then
exceeders[name] = exceeders[name] + 1
if exceeders[name] > limit_messages then
ban(name)
end
else
exceeders[name] = 1
end
message = message:sub(1, limit_message_length) .. ">8 >8 >8"
minetest.chat_send_all("<" .. name .. "> " .. message)
return true
else
if exceeders[name] then
exceeders[name] = nil
end
end
if block_special_chars then
local sc = false
local msg = ""
for i = 1, #message do
local c = message:sub(i,i)
if c >= " " and c <= last_char then
msg = msg .. c
else
sc = true
end
end
if sc then
if special_users[name] then
special_users[name] = special_users[name] + 1
if special_users[name] > limit_messages then
ban(name)
end
else
special_users[name] = 1
end
message = msg
minetest.chat_send_all("<" .. name .. "> " .. message)
return true
else
if special_users[name] then
special_users[name] = nil
end
end
end
end
minetest.register_on_chat_message(on_chat_message)

View File

@ -0,0 +1,2 @@
name = mcl_antispam
author = kay27

View File

@ -165,6 +165,20 @@ kick_cheaters (Kick Cheaters) bool false
# Cheat kicking threshold # Cheat kicking threshold
kick_threshold (Cheat Kicking Threshold) int 10 kick_threshold (Cheat Kicking Threshold) int 10
[Antispam]
# Maximum player messages in a sequence
limit_messages (Maximum player messages in a sequence) int 10
# Maximum message length
limit_message_length (Maximum message length) int 200
# Block special characters
block_special_chars (Block special characters) bool true
# Ban spammers
ban_spammers (Ban spammers) bool true
# Kick spammers
kick_spammers (Kick spammers) bool true
# Revoke shout priv for spammers
revoke_shout_for_spammers (Revoke shout priv for spammers) bool true
[Debugging] [Debugging]
# If enabled, this will show the itemstring of an item in the description. # If enabled, this will show the itemstring of an item in the description.
mcl_item_id_debug (Item ID Debug) bool false mcl_item_id_debug (Item ID Debug) bool false